Class: Spektr::Exp::Argument
Instance Attribute Summary collapse
-
#ast ⇒ Object
Returns the value of attribute ast.
-
#children ⇒ Object
Returns the value of attribute children.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from Base
#arguments, #body, #location, #options
Instance Method Summary collapse
-
#initialize(ast) ⇒ Argument
constructor
A new instance of Argument.
- #on_begin(node) ⇒ Object
- #on_const(node) ⇒ Object
- #on_send(node) ⇒ Object
- #on_str(node) ⇒ Object (also: #on_sym, #on_ivar)
- #process_ast(ast) ⇒ Object
Methods inherited from Base
#handler_missing, #process, #send?
Constructor Details
#initialize(ast) ⇒ Argument
Returns a new instance of Argument.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/spektr/exp/send.rb', line 37 def initialize(ast) @name = nil process_ast(ast) ast = ast.children.first if ast.type == :begin @ast = ast argument = if %i[xstr hash].include? ast.type ast elsif ast.type != :dstr && ast.children.first.is_a?(Parser::AST::Node) && ast.children.first.children.first.is_a?(Parser::AST::Node) ast.children.first.children.first elsif ast.type != :dstr && ast.children.first.is_a?(Parser::AST::Node) ast.children.first else ast end @type = argument.type @children = argument.children end |
Instance Attribute Details
#ast ⇒ Object
Returns the value of attribute ast.
35 36 37 |
# File 'lib/spektr/exp/send.rb', line 35 def ast @ast end |
#children ⇒ Object
Returns the value of attribute children.
35 36 37 |
# File 'lib/spektr/exp/send.rb', line 35 def children @children end |
#name ⇒ Object
Returns the value of attribute name.
35 36 37 |
# File 'lib/spektr/exp/send.rb', line 35 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
35 36 37 |
# File 'lib/spektr/exp/send.rb', line 35 def type @type end |
Instance Method Details
#on_begin(node) ⇒ Object
59 60 61 |
# File 'lib/spektr/exp/send.rb', line 59 def on_begin(node) process_all(node) end |
#on_const(node) ⇒ Object
71 72 73 |
# File 'lib/spektr/exp/send.rb', line 71 def on_const(node) @name ||= node.children[1] if node.children.first.nil? end |
#on_send(node) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/spektr/exp/send.rb', line 63 def on_send(node) if node.children.first.nil? @name ||= node.children[1] elsif node.is_a?(Parser::AST::Node) process_all(node) end end |
#on_str(node) ⇒ Object Also known as: on_sym, on_ivar
75 76 77 |
# File 'lib/spektr/exp/send.rb', line 75 def on_str(node) @name ||= node.children.first end |
#process_ast(ast) ⇒ Object
55 56 57 |
# File 'lib/spektr/exp/send.rb', line 55 def process_ast(ast) process(ast) end |