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.
1665 1666 1667 1668 1669 |
# File 'lib/syntax_tree/node.rb', line 1665 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
1663 1664 1665 |
# File 'lib/syntax_tree/node.rb', line 1663 def comments @comments end |
#name ⇒ Object (readonly)
- nil | Ident
-
the name of the block argument
1660 1661 1662 |
# File 'lib/syntax_tree/node.rb', line 1660 def name @name end |
Instance Method Details
#accept(visitor) ⇒ Object
1671 1672 1673 |
# File 'lib/syntax_tree/node.rb', line 1671 def accept(visitor) visitor.visit_blockarg(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
1675 1676 1677 |
# File 'lib/syntax_tree/node.rb', line 1675 def child_nodes [name] end |
#deconstruct_keys(keys) ⇒ Object
1681 1682 1683 |
# File 'lib/syntax_tree/node.rb', line 1681 def deconstruct_keys(keys) { name: name, location: location, comments: comments } end |
#format(q) ⇒ Object
1685 1686 1687 1688 |
# File 'lib/syntax_tree/node.rb', line 1685 def format(q) q.text("&") q.format(name) if name end |