Class: SyntaxTree::BlockArg
Overview
BlockArg represents declaring a block parameter on a method definition.
def method(&block); end
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#name ⇒ Object
readonly
- nil | Ident
-
the name of the block argument.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(name:, location:, comments: []) ⇒ BlockArg
constructor
A new instance of BlockArg.
Methods inherited from Node
Constructor Details
#initialize(name:, location:, comments: []) ⇒ BlockArg
Returns a new instance of BlockArg.
1713 1714 1715 1716 1717 |
# File 'lib/syntax_tree/node.rb', line 1713 def initialize(name:, location:, comments: []) @name = name @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
1711 1712 1713 |
# File 'lib/syntax_tree/node.rb', line 1711 def comments @comments end |
#name ⇒ Object (readonly)
- nil | Ident
-
the name of the block argument
1708 1709 1710 |
# File 'lib/syntax_tree/node.rb', line 1708 def name @name end |
Instance Method Details
#accept(visitor) ⇒ Object
1719 1720 1721 |
# File 'lib/syntax_tree/node.rb', line 1719 def accept(visitor) visitor.visit_blockarg(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
1723 1724 1725 |
# File 'lib/syntax_tree/node.rb', line 1723 def child_nodes [name] end |
#deconstruct_keys(keys) ⇒ Object
1729 1730 1731 |
# File 'lib/syntax_tree/node.rb', line 1729 def deconstruct_keys(keys) { name: name, location: location, comments: comments } end |
#format(q) ⇒ Object
1733 1734 1735 1736 |
# File 'lib/syntax_tree/node.rb', line 1733 def format(q) q.text("&") q.format(name) if name end |