Class: Fmt::Macro
Overview
Represents an uninvoked method call
A Macro is comprised of:
- name: Symbol
- arguments: Arguments
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
: Arguments.
-
#name ⇒ Object
readonly
: Symbol -- method name.
Attributes inherited from Model
AST Processors collapse
-
#on_arguments(node) ⇒ Object
Processes an arguments AST node.
-
#on_macro(node) ⇒ Object
Processes a macro AST node.
-
#on_name(node) ⇒ Object
Processes a procedure AST node.
Instance Method Summary collapse
-
#initialize(ast) ⇒ Macro
constructor
Constructor.
-
#to_h ⇒ Object
Hash representation of the model (required for pattern matching).
Methods inherited from Model
Methods included from Matchable
#deconstruct, #deconstruct_keys
Constructor Details
#initialize(ast) ⇒ Macro
Constructor
18 19 20 21 22 |
# File 'lib/fmt/models/macro.rb', line 18 def initialize(ast) @name = nil @arguments = Arguments.new(Node.new(:arguments)) super end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
: Arguments
14 15 16 |
# File 'lib/fmt/models/macro.rb', line 14 def arguments @arguments end |
#name ⇒ Object (readonly)
: Symbol -- method name
13 14 15 |
# File 'lib/fmt/models/macro.rb', line 13 def name @name end |
Instance Method Details
#on_arguments(node) ⇒ Object
Processes an arguments AST node
54 55 56 |
# File 'lib/fmt/models/macro.rb', line 54 def on_arguments(node) @arguments = Arguments.new(node) end |
#on_macro(node) ⇒ Object
Processes a macro AST node
40 41 42 |
# File 'lib/fmt/models/macro.rb', line 40 def on_macro(node) process_all node.children end |
#on_name(node) ⇒ Object
Processes a procedure AST node
47 48 49 |
# File 'lib/fmt/models/macro.rb', line 47 def on_name(node) @name = node.find(Symbol) end |
#to_h ⇒ Object
Hash representation of the model (required for pattern matching)
26 27 28 29 30 31 |
# File 'lib/fmt/models/macro.rb', line 26 def to_h super.merge( name: name, arguments: arguments&.to_h ) end |