Class: SyntaxTree::Args
- Inherits:
-
Object
- Object
- SyntaxTree::Args
- Defined in:
- lib/syntax_tree.rb
Overview
Args represents a list of arguments being passed to a method call or array literal.
method(first, second, third)
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
-
#parts ⇒ Object
readonly
- Array[ untyped ]
-
the arguments that this node wraps.
Instance Method Summary collapse
- #child_nodes ⇒ Object
- #format(q) ⇒ Object
-
#initialize(parts:, location:, comments: []) ⇒ Args
constructor
A new instance of Args.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(parts:, location:, comments: []) ⇒ Args
Returns a new instance of Args.
1108 1109 1110 1111 1112 |
# File 'lib/syntax_tree.rb', line 1108 def initialize(parts:, location:, comments: []) @parts = parts @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
1106 1107 1108 |
# File 'lib/syntax_tree.rb', line 1106 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
1103 1104 1105 |
# File 'lib/syntax_tree.rb', line 1103 def location @location end |
#parts ⇒ Object (readonly)
- Array[ untyped ]
-
the arguments that this node wraps
1100 1101 1102 |
# File 'lib/syntax_tree.rb', line 1100 def parts @parts end |
Instance Method Details
#child_nodes ⇒ Object
1114 1115 1116 |
# File 'lib/syntax_tree.rb', line 1114 def child_nodes parts end |
#format(q) ⇒ Object
1118 1119 1120 |
# File 'lib/syntax_tree.rb', line 1118 def format(q) q.seplist(parts) { |part| q.format(part) } end |
#pretty_print(q) ⇒ Object
1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 |
# File 'lib/syntax_tree.rb', line 1122 def pretty_print(q) q.group(2, "(", ")") do q.text("args") q.breakable q.group(2, "(", ")") { q.seplist(parts) { |part| q.pp(part) } } q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
1133 1134 1135 1136 1137 |
# File 'lib/syntax_tree.rb', line 1133 def to_json(*opts) { type: :args, parts: parts, loc: location, cmts: comments }.to_json( *opts ) end |