class SyntaxTree::Elsif
end
elsif other_variable
if variable
Elsif represents another clause in an if or unless chain.
def ===(other)
def ===(other) other.is_a?(Elsif) && predicate === other.predicate && statements === other.statements && consequent === other.consequent end
def accept(visitor)
def accept(visitor) visitor.visit_elsif(self) end
def child_nodes
def child_nodes [predicate, statements, consequent] end
def copy(predicate: nil, statements: nil, consequent: nil, location: nil)
def copy(predicate: nil, statements: nil, consequent: nil, location: nil) node = Elsif.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
def deconstruct_keys(_keys)
def deconstruct_keys(_keys) { predicate: predicate, statements: statements, consequent: consequent, location: location, comments: comments } end
def format(q)
def format(q) q.group do q.group do q.text("elsif ") q.nest("elsif".length - 1) { q.format(predicate) } end unless statements.empty? q.indent do q.breakable_force q.format(statements) end end if consequent q.group do q.breakable_force q.format(consequent) end end end end
def initialize(predicate:, statements:, consequent:, location:)
def initialize(predicate:, statements:, consequent:, location:) @predicate = predicate @statements = statements @consequent = consequent @location = location @comments = [] end