class SyntaxTree::WhileNode
While represents a while
loop.
while predicate end
Attributes
Node
-
the expression to be checked
Statements
-
the expressions to be executed
Public Class Methods
Source
# File lib/syntax_tree/node.rb, line 11964 def initialize(predicate:, statements:, location:) @predicate = predicate @statements = statements @location = location @comments = [] end
Public Instance Methods
Source
# File lib/syntax_tree/node.rb, line 12006 def ===(other) other.is_a?(WhileNode) && predicate === other.predicate && statements === other.statements end
Source
# File lib/syntax_tree/node.rb, line 11971 def accept(visitor) visitor.visit_while(self) end
Source
# File lib/syntax_tree/node.rb, line 11975 def child_nodes [predicate, statements] end
Also aliased as: deconstruct
Source
# File lib/syntax_tree/node.rb, line 11979 def copy(predicate: nil, statements: nil, location: nil) node = WhileNode.new( predicate: predicate || self.predicate, statements: statements || self.statements, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end
Source
# File lib/syntax_tree/node.rb, line 11993 def deconstruct_keys(_keys) { predicate: predicate, statements: statements, location: location, comments: comments } end
Source
# File lib/syntax_tree/node.rb, line 12002 def format(q) LoopFormatter.new("while", self).format(q) end
Source
# File lib/syntax_tree/node.rb, line 12011 def modifier? predicate.location.start_char > statements.location.start_char end