Class: SyntaxTree::ArgParen
- Inherits:
-
Object
- Object
- SyntaxTree::ArgParen
- Defined in:
- lib/syntax_tree.rb
Overview
ArgParen represents wrapping arguments to a method inside a set of parentheses.
method(argument)
In the example above, there would be an ArgParen node around the Args node that represents the set of arguments being sent to the method method. The argument child node can be nil if no arguments were passed, as in:
method()
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
- nil | Args | ArgsForward
-
the arguments inside the parentheses.
-
#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(arguments:, location:, comments: []) ⇒ ArgParen
constructor
A new instance of ArgParen.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(arguments:, location:, comments: []) ⇒ ArgParen
Returns a new instance of ArgParen.
1023 1024 1025 1026 1027 |
# File 'lib/syntax_tree.rb', line 1023 def initialize(arguments:, location:, comments: []) @arguments = arguments @location = location @comments = comments end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
- nil | Args | ArgsForward
-
the arguments inside the
parentheses
1015 1016 1017 |
# File 'lib/syntax_tree.rb', line 1015 def arguments @arguments end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
1021 1022 1023 |
# File 'lib/syntax_tree.rb', line 1021 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
1018 1019 1020 |
# File 'lib/syntax_tree.rb', line 1018 def location @location end |
Instance Method Details
#child_nodes ⇒ Object
1029 1030 1031 |
# File 'lib/syntax_tree.rb', line 1029 def child_nodes [arguments] end |
#format(q) ⇒ Object
1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 |
# File 'lib/syntax_tree.rb', line 1033 def format(q) unless arguments q.text("()") return end q.group(0, "(", ")") do q.indent do q.breakable("") q.format(arguments) end q.breakable("") end end |
#pretty_print(q) ⇒ Object
1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 |
# File 'lib/syntax_tree.rb', line 1048 def pretty_print(q) q.group(2, "(", ")") do q.text("arg_paren") q.breakable q.pp(arguments) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
1059 1060 1061 1062 1063 1064 1065 1066 |
# File 'lib/syntax_tree.rb', line 1059 def to_json(*opts) { type: :arg_paren, args: arguments, loc: location, cmts: comments }.to_json(*opts) end |