Class: Decode::Language::Ruby::Method

Inherits:
Definition show all
Defined in:
lib/decode/language/ruby/method.rb

Overview

A Ruby-specific method.

Direct Known Subclasses

Function

Instance Attribute Summary

Attributes inherited from Definition

#comments

Attributes inherited from Symbol

#kind, #language, #name, #parent

Instance Method Summary collapse

Methods inherited from Definition

#container?, #documentation, #initialize, #nested?, #qualified_form, #text

Methods inherited from Symbol

#initialize, #inspect, #key, #lexical_path, #path, #qualified_name

Constructor Details

This class inherits a constructor from Decode::Definition

Instance Method Details

#arguments_nodeObject

The node which contains the function arguments.



35
36
37
38
39
40
41
# File 'lib/decode/language/ruby/method.rb', line 35

def arguments_node
  if node = @node.children[1]
    if node.location.expression
      return node
    end
  end
end

#long_formObject

The long form of the method. e.g. def puts(*lines, separator: "\n").



45
46
47
48
49
50
51
52
53
# File 'lib/decode/language/ruby/method.rb', line 45

def long_form
  if arguments_node = self.arguments_node
    @node.location.keyword.join(
      arguments_node.location.expression
    ).source
  else
    self.short_form
  end
end

#short_formObject

The short form of the method. e.g. def puts.



30
31
32
# File 'lib/decode/language/ruby/method.rb', line 30

def short_form
  @node.location.keyword.join(@node.location.name).source
end