class SyntaxTree::WhileNode
While represents a while
loop.
while 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:, location:)
click to toggle source
# File lib/syntax_tree/node.rb, line 11945 def initialize(predicate:, statements:, location:) @predicate = predicate @statements = statements @location = location @comments = [] end
Public Instance Methods
===(other)
click to toggle source
# File lib/syntax_tree/node.rb, line 11987 def ===(other) other.is_a?(WhileNode) && predicate === other.predicate && statements === other.statements end
accept(visitor)
click to toggle source
# File lib/syntax_tree/node.rb, line 11952 def accept(visitor) visitor.visit_while(self) end
child_nodes()
click to toggle source
# File lib/syntax_tree/node.rb, line 11956 def child_nodes [predicate, statements] end
Also aliased as: deconstruct
copy(predicate: nil, statements: nil, location: nil)
click to toggle source
# File lib/syntax_tree/node.rb, line 11960 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
deconstruct_keys(_keys)
click to toggle source
# File lib/syntax_tree/node.rb, line 11974 def deconstruct_keys(_keys) { predicate: predicate, statements: statements, location: location, comments: comments } end
format(q)
click to toggle source
# File lib/syntax_tree/node.rb, line 11983 def format(q) LoopFormatter.new("while", self).format(q) end
modifier?()
click to toggle source
# File lib/syntax_tree/node.rb, line 11992 def modifier? predicate.location.start_char > statements.location.start_char end