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.
8789 8790 8791 8792 8793 8794 |
# File 'lib/syntax_tree/node.rb', line 8789 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
8787 8788 8789 |
# File 'lib/syntax_tree/node.rb', line 8787 def comments @comments end |
#operator ⇒ Object (readonly)
[String] the operator being used
8781 8782 8783 |
# File 'lib/syntax_tree/node.rb', line 8781 def operator @operator end |
#statement ⇒ Object (readonly)
[untyped] the statement on which to operate
8784 8785 8786 |
# File 'lib/syntax_tree/node.rb', line 8784 def statement @statement end |
Instance Method Details
#accept(visitor) ⇒ Object
8796 8797 8798 |
# File 'lib/syntax_tree/node.rb', line 8796 def accept(visitor) visitor.visit_unary(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
8800 8801 8802 |
# File 'lib/syntax_tree/node.rb', line 8800 def child_nodes [statement] end |
#deconstruct_keys(keys) ⇒ Object
8806 8807 8808 8809 8810 8811 8812 8813 |
# File 'lib/syntax_tree/node.rb', line 8806 def deconstruct_keys(keys) { operator: operator, statement: statement, location: location, comments: comments } end |
#format(q) ⇒ Object
8815 8816 8817 8818 |
# File 'lib/syntax_tree/node.rb', line 8815 def format(q) q.text(operator) q.format(statement) end |