Class: Yoda::Parsing::NodeObjects::MethodDefinition
- Inherits:
-
Object
- Object
- Yoda::Parsing::NodeObjects::MethodDefinition
- Defined in:
- lib/yoda/parsing/node_objects/method_definition.rb
Instance Attribute Summary collapse
- #namespace ⇒ Namespace readonly
- #node ⇒ ::Parser::AST::Node readonly
Instance Method Summary collapse
- #arg_node ⇒ Object
- #body_node ⇒ Object
- #full_name ⇒ String
-
#initialize(node, namespace) ⇒ MethodDefinition
constructor
A new instance of MethodDefinition.
- #name ⇒ Symbol
- #namespace_name ⇒ String
Constructor Details
#initialize(node, namespace) ⇒ MethodDefinition
Returns a new instance of MethodDefinition.
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
#namespace ⇒ Namespace (readonly)
10 11 12 |
# File 'lib/yoda/parsing/node_objects/method_definition.rb', line 10 def namespace @namespace end |
#node ⇒ ::Parser::AST::Node (readonly)
7 8 9 |
# File 'lib/yoda/parsing/node_objects/method_definition.rb', line 7 def node @node end |
Instance Method Details
#arg_node ⇒ Object
26 27 28 |
# File 'lib/yoda/parsing/node_objects/method_definition.rb', line 26 def arg_node node.children[-2] end |
#body_node ⇒ Object
30 31 32 |
# File 'lib/yoda/parsing/node_objects/method_definition.rb', line 30 def body_node node.children[-1] end |
#full_name ⇒ String
35 36 37 |
# File 'lib/yoda/parsing/node_objects/method_definition.rb', line 35 def full_name "#{namespace.full_name}##{name}" end |
#name ⇒ Symbol
22 23 24 |
# File 'lib/yoda/parsing/node_objects/method_definition.rb', line 22 def name node.children[-3] end |
#namespace_name ⇒ String
40 41 42 |
# File 'lib/yoda/parsing/node_objects/method_definition.rb', line 40 def namespace_name namespace.full_name end |