class SyntaxTree::UnlessNode
Unless represents the first clause in an unless
chain.
unless predicate end
Attributes
predicate[R]
Node
-
the expression to be checked
statements[R]
Statements
-
the expressions to be executed
Public Class Methods
new(predicate:, statements:, consequent:, location:)
click to toggle source
# File lib/syntax_tree/node.rb, line 11321 def initialize(predicate:, statements:, consequent:, location:) @predicate = predicate @statements = statements @consequent = consequent @location = location @comments = [] end
Public Instance Methods
===(other)
click to toggle source
# File lib/syntax_tree/node.rb, line 11366 def ===(other) other.is_a?(UnlessNode) && predicate === other.predicate && statements === other.statements && consequent === other.consequent end
accept(visitor)
click to toggle source
# File lib/syntax_tree/node.rb, line 11329 def accept(visitor) visitor.visit_unless(self) end
child_nodes()
click to toggle source
# File lib/syntax_tree/node.rb, line 11333 def child_nodes [predicate, statements, consequent] end
Also aliased as: deconstruct
copy(predicate: nil, statements: nil, consequent: nil, location: nil)
click to toggle source
# File lib/syntax_tree/node.rb, line 11337 def copy(predicate: nil, statements: nil, consequent: nil, location: nil) node = UnlessNode.new( predicate: predicate || self.predicate, statements: statements || self.statements, consequent: consequent || self.consequent, 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 11352 def deconstruct_keys(_keys) { predicate: predicate, statements: statements, consequent: consequent, location: location, comments: comments } end
format(q)
click to toggle source
# File lib/syntax_tree/node.rb, line 11362 def format(q) ConditionalFormatter.new("unless", self).format(q) end
modifier?()
click to toggle source
Checks if the node was originally found in the modifier form.
# File lib/syntax_tree/node.rb, line 11372 def modifier? predicate.location.start_char > statements.location.start_char end