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
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(operator:, statement:, location:, comments: []) ⇒ Unary
Returns a new instance of Unary.
9018 9019 9020 9021 9022 9023 |
# File 'lib/syntax_tree/node.rb', line 9018 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
9016 9017 9018 |
# File 'lib/syntax_tree/node.rb', line 9016 def comments @comments end |
#operator ⇒ Object (readonly)
- String
-
the operator being used
9010 9011 9012 |
# File 'lib/syntax_tree/node.rb', line 9010 def operator @operator end |
#statement ⇒ Object (readonly)
- untyped
-
the statement on which to operate
9013 9014 9015 |
# File 'lib/syntax_tree/node.rb', line 9013 def statement @statement end |
Instance Method Details
#accept(visitor) ⇒ Object
9025 9026 9027 |
# File 'lib/syntax_tree/node.rb', line 9025 def accept(visitor) visitor.visit_unary(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
9029 9030 9031 |
# File 'lib/syntax_tree/node.rb', line 9029 def child_nodes [statement] end |
#deconstruct_keys(_keys) ⇒ Object
9035 9036 9037 9038 9039 9040 9041 9042 |
# File 'lib/syntax_tree/node.rb', line 9035 def deconstruct_keys(_keys) { operator: operator, statement: statement, location: location, comments: comments } end |
#format(q) ⇒ Object
9044 9045 9046 9047 |
# File 'lib/syntax_tree/node.rb', line 9044 def format(q) q.text(operator) q.format(statement) end |