lib/docrb/lib/docrb/ruby_parser.rb
def parse_method_args(node)
      node.children
          .find { |n| n.try?(:type) == :args }
        &.to_a
        &.map do |n|
          {
            type: n.type,
            name: n.children.first
          }.tap do |m|
            if n.children.length > 1
              val = n.children[1]
              represented_type = nil
              represented_value = nil
              case val.type
              when true, :true
                represented_type = :bool
                represented_value = true
              when false, :false
                represented_type = :bool
                represented_value = false
              when :nil
                represented_type = :nil
                represented_value = :nil
              when :send
                represented_type = :send
                represented_value = {
                  target: parse_class_path(val.children.first).flatten.compact,
                  name: val.children.last
                }
              else
                represented_type = val.type
                represented_value = val.children.first
              end
              m[:value_type] = represented_type
              m[:value] = represented_value
            end
          end
        end
    end
# Parses an argument list of a method defintion
#
# node - The method's node definition
#
# Returns a list of standardised hashes representing all method's arguments
Parses an argument list of a method defintion
node - The method's node definition

Returns a list of standardised hashes representing all method's arguments
Parses an argument list of a method defintion node - The method ' s node definition Returns a list of standardised hashes representing all method ' s arguments
def parse_method_args(node)
      node.children
          .find { |n| n.try?(:type) == :args }
        &.to_a
        &.map do |n|
          {
            type: n.type,
            name: n.children.first
          }.tap do |m|
            if n.children.length > 1
              val = n.children[1]
              represented_type = nil
              represented_value = nil
              case val.type
              when true, :true
                represented_type = :bool
                represented_value = true
              when false, :false
                represented_type = :bool
                represented_value = false
              when :nil
                represented_type = :nil
                represented_value = :nil
              when :send
                represented_type = :send
                represented_value = {
                  target: parse_class_path(val.children.first).flatten.compact,
                  name: val.children.last
                }
              else
                represented_type = val.type
                represented_value = val.children.first
              end
              m[:value_type] = represented_type
              m[:value] = represented_value
            end
          end
        end
    end
def parse_method_args ( node ) node . children . find { | n | n . try? ( :type ) == :args } &. to_a &. map do | n | { type : n . type , name : n . children . first } . tap do | m | if n . children . length > 1 val = n . children [ 1 ] represented_type = nil represented_value = nil case val . type when true , :true represented_type = :bool represented_value = true when false , :false represented_type = :bool represented_value = false when :nil represented_type = :nil represented_value = :nil when :send represented_type = :send represented_value = { target : parse_class_path ( val . children . first ) . flatten . compact , name : val . children . last } else represented_type = val . type represented_value = val . children . first end m [ :value_type ] = represented_type m [ :value ] = represented_value end end end end
Parses an argument list of a method defintion
node - The method's node definition
Parses an argument list of a method defintion node - The method ' s node definition
node