class SyntaxTree::For
end
for value in list do
For represents using a for
loop.
def ===(other)
def ===(other) other.is_a?(For) && index === other.index && collection === other.collection && statements === other.statements end
def accept(visitor)
def accept(visitor) visitor.visit_for(self) end
def child_nodes
def child_nodes [index, collection, statements] end
def copy(index: nil, collection: nil, statements: nil, location: nil)
def copy(index: nil, collection: nil, statements: nil, location: nil) node = For.new( index: index || self.index, collection: collection || self.collection, statements: statements || self.statements, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end
def deconstruct_keys(_keys)
def deconstruct_keys(_keys) { index: index, collection: collection, statements: statements, location: location, comments: comments } end
def format(q)
def format(q) q.group do q.text("for ") q.group { q.format(index) } q.text(" in ") q.format(collection) unless statements.empty? q.indent do q.breakable_force q.format(statements) end end q.breakable_force q.text("end") end end
def initialize(index:, collection:, statements:, location:)
def initialize(index:, collection:, statements:, location:) @index = index @collection = collection @statements = statements @location = location @comments = [] end