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
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(name:, location:, comments: []) ⇒ BlockArg
Returns a new instance of BlockArg.
1752 1753 1754 1755 1756 |
# File 'lib/syntax_tree/node.rb', line 1752 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
1750 1751 1752 |
# File 'lib/syntax_tree/node.rb', line 1750 def comments @comments end |
#name ⇒ Object (readonly)
[nil | Ident] the name of the block argument
1747 1748 1749 |
# File 'lib/syntax_tree/node.rb', line 1747 def name @name end |
Instance Method Details
#accept(visitor) ⇒ Object
1758 1759 1760 |
# File 'lib/syntax_tree/node.rb', line 1758 def accept(visitor) visitor.visit_blockarg(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
1762 1763 1764 |
# File 'lib/syntax_tree/node.rb', line 1762 def child_nodes [name] end |
#deconstruct_keys(_keys) ⇒ Object
1768 1769 1770 |
# File 'lib/syntax_tree/node.rb', line 1768 def deconstruct_keys(_keys) { name: name, location: location, comments: comments } end |
#format(q) ⇒ Object
1772 1773 1774 1775 |
# File 'lib/syntax_tree/node.rb', line 1772 def format(q) q.text("&") q.format(name) if name end |