<commit_before>class Ruby
  def self.menu
    "
    - .classes/
    - .re_index_fast_ri/
    - .docs/
      > Ruby docs
      @$ qri -h

      > Eval code
      | Evaluate the ruby code on adjascent lines, until a '> ...' heading.
      @eval
      puts('hi')
    - @eval/
    - @technologies/ruby/
    - language docs/
      > Listing and categories of gems
      @ https://www.ruby-toolbox.com/
    "
  end

  def self.classes clazz=nil, method=nil

    # If no params, show list of classes

    if clazz.nil?
      result = []
      ObjectSpace.each_object(Class) do |c|
        name = c.to_s
        next if name =~ /^#/
        result << "- #{name}/\n"
      end
      return result.sort.join
    end

    # If just class, show methods

    if method.nil?
      result = ""
      result << Kernel.const_get(clazz).instance_methods(false).sort.
        collect {|i| "- #{i}/" }.join("\n")
      result << Kernel.const_get(clazz).methods(false).sort.
        collect {|i| "- ::#{i}/" }.join("\n")
      return result
    end

    # If method passed, lookup method's doc

    method = "##{method}" unless method =~ /^::/
    command = "qri #{clazz}#{method}"
    Console[command].gsub(/\C-[.+?m/, '').gsub(/^/, '| ').gsub(/^\| +$/, '|')
  end

  def self.re_index_fast_ri
    Console.run "fastri-server -b"
  end
end
<commit_msg>Ruby: custom+next and custom+previous.<commit_after>class Ruby
  def self.menu
    "
    - .classes/
    - .re_index_fast_ri/
    - .docs/
      > Ruby docs
      @$ qri -h

      > Eval code
      | Evaluate the ruby code on adjascent lines, until a '> ...' heading.
      @eval
      puts('hi')
    - @eval/
    - @technologies/ruby/
    - language docs/
      > Listing and categories of gems
      @ https://www.ruby-toolbox.com/
    "
  end

  def self.classes clazz=nil, method=nil

    # If no params, show list of classes

    if clazz.nil?
      result = []
      ObjectSpace.each_object(Class) do |c|
        name = c.to_s
        next if name =~ /^#/
        result << "- #{name}/\n"
      end
      return result.sort.join
    end

    # If just class, show methods

    if method.nil?
      result = ""
      result << Kernel.const_get(clazz).instance_methods(false).sort.
        collect {|i| "- #{i}/" }.join("\n")
      result << Kernel.const_get(clazz).methods(false).sort.
        collect {|i| "- ::#{i}/" }.join("\n")
      return result
    end

    # If method passed, lookup method's doc

    method = "##{method}" unless method =~ /^::/
    command = "qri #{clazz}#{method}"
    Console[command].gsub(/\C-[.+?m/, '').gsub(/^/, '| ').gsub(/^\| +$/, '|')
  end

  def self.re_index_fast_ri
    Console.run "fastri-server -b"
  end

  # Ruby mode shortcuts custom+next and custom+previous
  #
  # To use them, add this line:
  # ~/.el4r/init.rb
  #   | Ruby.keys
  def self.keys
    Keys.custom_next(:ruby_mode_map) {
      Move.to_end
      Search.forward "^ *def ", :beginning=>1
    }

    Keys.custom_previous(:ruby_mode_map) {
      Search.backward "^ *def "
    }
  end

end

{'fraction_non_alphanumeric': 0.1629287598944591, 'fraction_numerical': 0.0006596306068601583, 'mean_word_length': 1.9619140625, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 12, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3344235', 'n_tokens_mistral': 1105, 'n_tokens_neox': 1061, 'n_words': 250}