Class: SyntaxTree::MethodAddBlock
- Inherits:
-
Object
- Object
- SyntaxTree::MethodAddBlock
- Defined in:
- lib/syntax_tree.rb
Overview
MethodAddBlock represents a method call with a block argument.
method {}
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
- BraceBlock | DoBlock
-
the block being sent with the method call.
-
#call ⇒ Object
readonly
- Call | Command | CommandCall | FCall | MethodAddArg
-
the method call.
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
Instance Method Summary collapse
- #child_nodes ⇒ Object
- #format(q) ⇒ Object
-
#initialize(call:, block:, location:, comments: []) ⇒ MethodAddBlock
constructor
A new instance of MethodAddBlock.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(call:, block:, location:, comments: []) ⇒ MethodAddBlock
Returns a new instance of MethodAddBlock.
7744 7745 7746 7747 7748 7749 |
# File 'lib/syntax_tree.rb', line 7744 def initialize(call:, block:, location:, comments: []) @call = call @block = block @location = location @comments = comments end |
Instance Attribute Details
#block ⇒ Object (readonly)
- BraceBlock | DoBlock
-
the block being sent with the method call
7736 7737 7738 |
# File 'lib/syntax_tree.rb', line 7736 def block @block end |
#call ⇒ Object (readonly)
- Call | Command | CommandCall | FCall | MethodAddArg
-
the method call
7733 7734 7735 |
# File 'lib/syntax_tree.rb', line 7733 def call @call end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
7742 7743 7744 |
# File 'lib/syntax_tree.rb', line 7742 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
7739 7740 7741 |
# File 'lib/syntax_tree.rb', line 7739 def location @location end |
Instance Method Details
#child_nodes ⇒ Object
7751 7752 7753 |
# File 'lib/syntax_tree.rb', line 7751 def child_nodes [call, block] end |
#format(q) ⇒ Object
7755 7756 7757 7758 |
# File 'lib/syntax_tree.rb', line 7755 def format(q) q.format(call) q.format(block) end |
#pretty_print(q) ⇒ Object
7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 |
# File 'lib/syntax_tree.rb', line 7760 def pretty_print(q) q.group(2, "(", ")") do q.text("method_add_block") q.breakable q.pp(call) q.breakable q.pp(block) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
7774 7775 7776 7777 7778 7779 7780 7781 7782 |
# File 'lib/syntax_tree.rb', line 7774 def to_json(*opts) { type: :method_add_block, call: call, block: block, loc: location, cmts: comments }.to_json(*opts) end |