A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://ruby-syntax-tree.github.io/syntax_tree/SyntaxTree/Formatter/../For.html below:

class SyntaxTree::For - RDoc Documentation

  1. SyntaxTree::
  2. For
class SyntaxTree::For

For represents using a for loop.

for value in list do
end
Attributes
Node

the object being enumerated in the loop

MLHS | VarField

the variable declaration being used to

pull values out of the object being enumerated

Public Class Methods

Source

def initialize(index:, collection:, statements:, location:)
  @index = index
  @collection = collection
  @statements = statements
  @location = location
  @comments = []
end
Public Instance Methods

Source

def ===(other)
  other.is_a?(For) && index === other.index &&
    collection === other.collection && statements === other.statements
end

Source

def accept(visitor)
  visitor.visit_for(self)
end

Source

def child_nodes
  [index, collection, statements]
end

Source

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

Source

def deconstruct_keys(_keys)
  {
    index: index,
    collection: collection,
    statements: statements,
    location: location,
    comments: comments
  }
end

Source

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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4