Class: SyntaxTree::MethodAddBlock
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
-
the method call.
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
Attributes inherited from Node
Instance Method Summary collapse
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ 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.
6922 6923 6924 6925 6926 6927 |
# File 'lib/syntax_tree/node.rb', line 6922 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
6917 6918 6919 |
# File 'lib/syntax_tree/node.rb', line 6917 def block @block end |
#call ⇒ Object (readonly)
- Call | Command | CommandCall | FCall
-
the method call
6914 6915 6916 |
# File 'lib/syntax_tree/node.rb', line 6914 def call @call end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
6920 6921 6922 |
# File 'lib/syntax_tree/node.rb', line 6920 def comments @comments end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
6929 6930 6931 |
# File 'lib/syntax_tree/node.rb', line 6929 def child_nodes [call, block] end |
#deconstruct_keys(keys) ⇒ Object
6935 6936 6937 |
# File 'lib/syntax_tree/node.rb', line 6935 def deconstruct_keys(keys) { call: call, block: block, location: location, comments: comments } end |
#format(q) ⇒ Object
6939 6940 6941 6942 |
# File 'lib/syntax_tree/node.rb', line 6939 def format(q) q.format(call) q.format(block) end |
#pretty_print(q) ⇒ Object
6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 |
# File 'lib/syntax_tree/node.rb', line 6944 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
6958 6959 6960 6961 6962 6963 6964 6965 6966 |
# File 'lib/syntax_tree/node.rb', line 6958 def to_json(*opts) { type: :method_add_block, call: call, block: block, loc: location, cmts: comments }.to_json(*opts) end |