Case
represents the beginning of a case chain.
case value when 1 "one" when 2 "two" else "number" endAttributes
In
| When
the next clause in the chain
Kw
the keyword that opens this expression
Node
optional value being switched on
def initialize(keyword:, value:, consequent:, location:) @keyword = keyword @value = value @consequent = consequent @location = location @comments = [] endPublic Instance Methods Source
def ===(other) other.is_a?(Case) && keyword === other.keyword && value === other.value && consequent === other.consequent endSource
def accept(visitor) visitor.visit_case(self) endSource
def child_nodes [keyword, value, consequent] endSource
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 endSource
def deconstruct_keys(_keys) { keyword: keyword, value: value, consequent: consequent, location: location, comments: comments } endSource
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