Module: RD::MethodParse

### Home Classes Methods

### In Files

- lib/rd/rdvisitor.rb

### Methods

- ::analize_method
- ::kind2num
- ::kind2str
- ::make_method_index
- ::make_mindex_label
- ::str2kind
- ::tr_method

### Files

- post-install

### Class/Module Index

Quicksearch

- RD
- RD::AutoLabel
- RD::BlockElement
- RD::Code
- RD::ComplexListItem
- RD::DescList
- RD::DescListItem
- RD::DescListItem::Term
- RD::DocumentElement
- RD::DocumentStructure
- RD::Element
- RD::ElementRelationship
- RD::Emphasis
- RD::EnumList
- RD::EnumListItem
- RD::Filter
- RD::Filter::FileInclude
- RD::Footnote
- RD::Headline
- RD::Include
- RD::Index
- RD::InlineElement
- RD::InlineIncludable
- RD::ItemList
- RD::ItemListItem
- RD::Keyboard
- RD::LabelComposable
- RD::LabeledElement
- RD::List
- RD::ListItem
- RD::ListItemComposable
- RD::MethodList
- RD::MethodListItem
- RD::MethodListItem::Term
- RD::MethodParse
- RD::NonterminalElement
- RD::NonterminalInline
- RD::OutputFormatVisitor
- RD::ParserUtility
- RD::Part
- RD::RBLFile
- RD::RBLSuite
- RD::RD2HTMLExtVisitor
- RD::RD2HTMLExtVisitor::EnableBr
- RD::RD2HTMLExtVisitor::HeadElement
- RD::RD2HTMLExtVisitor::HeadLineTitle
- RD::RD2HTMLExtVisitor::HeadlineSecno
- RD::RD2HTMLExtVisitor::NativeInline
- RD::RD2HTMLExtVisitor::RefExtension
- RD::RD2HTMLVisitor
- RD::RD2MANVisitor
- RD::RD2RDOVisitor
- RD::RD2RMIVisitor
- RD::RDElement
- RD::RDInlineParser
- RD::RDParser
- RD::RDTree
- RD::RDVisitor
- RD::Reference
- RD::Reference::Label
- RD::Reference::RDLabel
- RD::Reference::TemporaryLabel
- RD::Reference::URL
- RD::ReferenceResolver
- RD::SearchFile
- RD::StringElement
- RD::TerminalElement
- RD::TerminalInline
- RD::TextBlock
- RD::Tree
- RD::Var
- RD::Verb
- RD::Verbatim
- RD::Version
- RD::Visitor
- Array

No matching classes.

# RD::MethodParse

## module RD::MethodParse

this module provide several functions for MehotList.

### Constants

KIND2NUM

### Public Class Methods

analize_method(method) click to toggle source

    # File lib/rd/rdvisitor.rb, line 58
    def analize_method(method)
      klass = nil
      args = nil
      kind = nil
      if /[^{(\s]+/ =~ method
        method = $&
        args = $'                   # '
      end

      if /^(.*)(#|::|\.)/ =~ method
        klass = $1
        kind = str2kind($2)
        method = $'                 # '
      end

      if klass == "function" and kind == :instance_method
        kind = :function
      end

      [klass, kind, method, args]
    end

kind2num(str) click to toggle source

    # File lib/rd/rdvisitor.rb, line 106
    def kind2num(str)
      KIND2NUM[str]
    end

kind2str(int) click to toggle source

    # File lib/rd/rdvisitor.rb, line 93
    def kind2str(int)
      case int
      when :instance_method, :function
        '#'
      when :class_method
        '.'
      when :constant
        '::'
      end
    end

make_method_index(tree) click to toggle source

    # File lib/rd/rdvisitor.rb, line 192
    def make_method_index(tree)
      indexes = []
      tree.each do |i|
        if i.is_a?(MethodListItem)
          klass, kind, method, args = analize_method(i.term.content)
          indexes.push([klass, kind2num(kind), method, kind]) if kind
        end
      end
      indexes.uniq!
      indexes.sort.each {|i| i[1] = i.pop}
    end

make_mindex_label(element) click to toggle source

    # File lib/rd/rdvisitor.rb, line 111
    def make_mindex_label(element)
      klass, kind, method = analize_method(element.label)
      case kind
      when :class_method
        klass + "_S_" + tr_method(method)
      when :instance_method
        klass + "_" + tr_method(method)
      when :constant
        klass + "_" + method
      when :function
        "function_" + tr_method(method)
      else
        element.label
      end
    end

str2kind(str) click to toggle source

    # File lib/rd/rdvisitor.rb, line 81
    def str2kind(str)
      case str
      when '#'
        :instance_method
      when '.'
        :class_method
      when '::'
        :constant
      end
    end

tr_method(method) click to toggle source

    # File lib/rd/rdvisitor.rb, line 128
    def tr_method(method)
      case method
      when "[]"
        "ref_"
      when "[]="
        "set_"
      when "+"
        "plus_"
      when "+@"
        "uplus_"
      when "-"
        "minus_"
      when "-@"
        "uminus_"
      when "*"
        "mul_"
      when "/"
        "div_"
      when "%"
        "mod_"
      when "**"
        "power_"
      when "~"
        "inv_"
      when "=="
        "eq_"
      when "==="
        "eqq_"
      when "=~"
        "match_"
      when "&"
        "and_"
      when "|"
        "or_"
      when "<<"
        "lshift_"
      when ">>"
        "rshift_"
      when "<=>"
        "cmp_"
      when "<"
        "lt_"
      when "<="
        "le_"
      when ">"
        "gt_"
      when ">="
        "ge_"
      when "^"
        "xor_"
      when "`"
        "backquote_"
      when /!$/
        $` + "_bang"     # `
      when /\?$/
        $` + "_p"        # `
      when /=$/
        $` + "_eq"       # `
      else
        method
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.