class SyntaxTree::Unary
Unary
represents a unary method being called on an expression, as in +!+ or +~+.
!value
Attributes
- String
-
the operator being used
Node
-
the statement on which to operate
Public Class Methods
Source
# File lib/syntax_tree/node.rb, line 11186 def initialize(operator:, statement:, location:) @operator = operator @statement = statement @location = location @comments = [] end
Public Instance Methods
Source
# File lib/syntax_tree/node.rb, line 11229 def ===(other) other.is_a?(Unary) && operator === other.operator && statement === other.statement end
Source
# File lib/syntax_tree/node.rb, line 11193 def accept(visitor) visitor.visit_unary(self) end
Source
# File lib/syntax_tree/node.rb, line 11197 def child_nodes [statement] end
Also aliased as: deconstruct
Source
# File lib/syntax_tree/node.rb, line 11201 def copy(operator: nil, statement: nil, location: nil) node = Unary.new( operator: operator || self.operator, statement: statement || self.statement, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end
Source
# File lib/syntax_tree/node.rb, line 11215 def deconstruct_keys(_keys) { operator: operator, statement: statement, location: location, comments: comments } end
Source
# File lib/syntax_tree/node.rb, line 11224 def format(q) q.text(operator) q.format(statement) end