class SyntaxTree::Unary
Unary
represents a unary method being called on an expression, as in +!+ or +~+.
!value
Attributes
operator[R]
- String
-
the operator being used
statement[R]
Node
-
the statement on which to operate
Public Class Methods
new(operator:, statement:, location:)
click to toggle source
# File lib/syntax_tree/node.rb, line 11171 def initialize(operator:, statement:, location:) @operator = operator @statement = statement @location = location @comments = [] end
Public Instance Methods
===(other)
click to toggle source
# File lib/syntax_tree/node.rb, line 11214 def ===(other) other.is_a?(Unary) && operator === other.operator && statement === other.statement end
accept(visitor)
click to toggle source
# File lib/syntax_tree/node.rb, line 11178 def accept(visitor) visitor.visit_unary(self) end
child_nodes()
click to toggle source
# File lib/syntax_tree/node.rb, line 11182 def child_nodes [statement] end
Also aliased as: deconstruct
copy(operator: nil, statement: nil, location: nil)
click to toggle source
# File lib/syntax_tree/node.rb, line 11186 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
deconstruct_keys(_keys)
click to toggle source
# File lib/syntax_tree/node.rb, line 11200 def deconstruct_keys(_keys) { operator: operator, statement: statement, location: location, comments: comments } end
format(q)
click to toggle source
# File lib/syntax_tree/node.rb, line 11209 def format(q) q.text(operator) q.format(statement) end