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/Case.html below:

class SyntaxTree::Case - RDoc Documentation

  1. SyntaxTree::
  2. Case
class SyntaxTree::Case

Case represents the beginning of a case chain.

case value
when 1
  "one"
when 2
  "two"
else
  "number"
end
Attributes
In | When

the next clause in the chain

Kw

the keyword that opens this expression

nil | Node

optional value being switched on

Public Class Methods

Source

def initialize(keyword:, value:, consequent:, location:)
  @keyword = keyword
  @value = value
  @consequent = consequent
  @location = location
  @comments = []
end
Public Instance Methods

Source

def ===(other)
  other.is_a?(Case) && keyword === other.keyword && value === other.value &&
    consequent === other.consequent
end

Source

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

Source

def child_nodes
  [keyword, value, consequent]
end

Source

def copy(keyword: nil, value: nil, consequent: nil, location: nil)
  node =
    Case.new(
      keyword: keyword || self.keyword,
      value: value || self.value,
      consequent: consequent || self.consequent,
      location: location || self.location
    )

  node.comments.concat(comments.map(&:copy))
  node
end

Source

def deconstruct_keys(_keys)
  {
    keyword: keyword,
    value: value,
    consequent: consequent,
    location: location,
    comments: comments
  }
end

Source

def format(q)
  q.group do
    q.format(keyword)

    if value
      q.text(" ")
      q.format(value)
    end

    q.breakable_force
    q.format(consequent)
    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