In
represents using the in
keyword within the Ruby 2.7+ pattern matching syntax.
case value in pattern endAttributes
In
| Else
the next clause in the chain
Node
the pattern to check against
Statements
the expressions to execute if the pattern matched
def initialize(pattern:, statements:, consequent:, location:) @pattern = pattern @statements = statements @consequent = consequent @location = location @comments = [] endPublic Instance Methods Source
def ===(other) other.is_a?(In) && pattern === other.pattern && statements === other.statements && consequent === other.consequent endSource
def accept(visitor) visitor.visit_in(self) endSource
def child_nodes [pattern, statements, consequent] endSource
def copy(pattern: nil, statements: nil, consequent: nil, location: nil) node = In.new( pattern: pattern || self.pattern, statements: statements || self.statements, consequent: consequent || self.consequent, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node endSource
def deconstruct_keys(_keys) { pattern: pattern, statements: statements, consequent: consequent, location: location, comments: comments } endSource
def format(q) keyword = "in " pattern = self.pattern consequent = self.consequent q.group do q.text(keyword) q.nest(keyword.length) { q.format(pattern) } q.text(" then") if pattern.is_a?(RangeNode) && pattern.right.nil? unless statements.empty? q.indent do q.breakable_force q.format(statements) end end if consequent q.breakable_force q.format(consequent) 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