Class: Yoda::Parsing::NodeObjects::MethodDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/yoda/parsing/node_objects/method_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node, namespace) ⇒ MethodDefinition

Returns a new instance of MethodDefinition.

Parameters:

  • node (::Parser::AST::Node)
  • namespace (Namespace)


14
15
16
17
18
19
# File 'lib/yoda/parsing/node_objects/method_definition.rb', line 14

def initialize(node, namespace)
  fail ArgumentError, node unless node.is_a?(::Parser::AST::Node)
  fail ArgumentError, namespace unless namespace.is_a?(Namespace)
  @node = node
  @namespace = namespace
end

Instance Attribute Details

#namespaceNamespace (readonly)

Returns:



10
11
12
# File 'lib/yoda/parsing/node_objects/method_definition.rb', line 10

def namespace
  @namespace
end

#node::Parser::AST::Node (readonly)

Returns:

  • (::Parser::AST::Node)


7
8
9
# File 'lib/yoda/parsing/node_objects/method_definition.rb', line 7

def node
  @node
end

Instance Method Details

#arg_nodeObject



26
27
28
# File 'lib/yoda/parsing/node_objects/method_definition.rb', line 26

def arg_node
  node.children[-2]
end

#body_nodeObject



30
31
32
# File 'lib/yoda/parsing/node_objects/method_definition.rb', line 30

def body_node
  node.children[-1]
end

#full_nameString

Returns:

  • (String)


35
36
37
# File 'lib/yoda/parsing/node_objects/method_definition.rb', line 35

def full_name
  "#{namespace.full_name}##{name}"
end

#nameSymbol

Returns:

  • (Symbol)


22
23
24
# File 'lib/yoda/parsing/node_objects/method_definition.rb', line 22

def name
  node.children[-3]
end

#namespace_nameString

Returns:

  • (String)


40
41
42
# File 'lib/yoda/parsing/node_objects/method_definition.rb', line 40

def namespace_name
  namespace.full_name
end