Class: SyntaxTree::Unary
Overview
Unary represents a unary method being called on an expression, as in ! or ~.
!value
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#operator ⇒ Object
readonly
- String
-
the operator being used.
-
#statement ⇒ Object
readonly
- untyped
-
the statement on which to operate.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(operator:, statement:, location:, comments: []) ⇒ Unary
constructor
A new instance of Unary.
Methods inherited from Node
Constructor Details
#initialize(operator:, statement:, location:, comments: []) ⇒ Unary
Returns a new instance of Unary.
8228 8229 8230 8231 8232 8233 |
# File 'lib/syntax_tree/node.rb', line 8228 def initialize(operator:, statement:, location:, comments: []) @operator = operator @statement = statement @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
8226 8227 8228 |
# File 'lib/syntax_tree/node.rb', line 8226 def comments @comments end |
#operator ⇒ Object (readonly)
- String
-
the operator being used
8220 8221 8222 |
# File 'lib/syntax_tree/node.rb', line 8220 def operator @operator end |
#statement ⇒ Object (readonly)
- untyped
-
the statement on which to operate
8223 8224 8225 |
# File 'lib/syntax_tree/node.rb', line 8223 def statement @statement end |
Instance Method Details
#accept(visitor) ⇒ Object
8235 8236 8237 |
# File 'lib/syntax_tree/node.rb', line 8235 def accept(visitor) visitor.visit_unary(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
8239 8240 8241 |
# File 'lib/syntax_tree/node.rb', line 8239 def child_nodes [statement] end |
#deconstruct_keys(keys) ⇒ Object
8245 8246 8247 8248 8249 8250 8251 8252 |
# File 'lib/syntax_tree/node.rb', line 8245 def deconstruct_keys(keys) { operator: operator, statement: statement, location: location, comments: comments } end |
#format(q) ⇒ Object
8254 8255 8256 8257 |
# File 'lib/syntax_tree/node.rb', line 8254 def format(q) q.text(operator) q.format(statement) end |