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.
9074 9075 9076 9077 9078 9079 |
# File 'lib/syntax_tree/node.rb', line 9074 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
9072 9073 9074 |
# File 'lib/syntax_tree/node.rb', line 9072 def comments @comments end |
#operator ⇒ Object (readonly)
- String
-
the operator being used
9066 9067 9068 |
# File 'lib/syntax_tree/node.rb', line 9066 def operator @operator end |
#statement ⇒ Object (readonly)
- untyped
-
the statement on which to operate
9069 9070 9071 |
# File 'lib/syntax_tree/node.rb', line 9069 def statement @statement end |
Instance Method Details
#accept(visitor) ⇒ Object
9081 9082 9083 |
# File 'lib/syntax_tree/node.rb', line 9081 def accept(visitor) visitor.visit_unary(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
9085 9086 9087 |
# File 'lib/syntax_tree/node.rb', line 9085 def child_nodes [statement] end |
#deconstruct_keys(_keys) ⇒ Object
9091 9092 9093 9094 9095 9096 9097 9098 |
# File 'lib/syntax_tree/node.rb', line 9091 def deconstruct_keys(_keys) { operator: operator, statement: statement, location: location, comments: comments } end |
#format(q) ⇒ Object
9100 9101 9102 9103 |
# File 'lib/syntax_tree/node.rb', line 9100 def format(q) q.text(operator) q.format(statement) end |