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

class SyntaxTree::FndPtn - RDoc Documentation

  1. SyntaxTree::
  2. FndPtn
class SyntaxTree::FndPtn

FndPtn represents matching against a pattern where you find a pattern in an array using the Ruby 3.0+ pattern matching syntax.

case value
in [*, 7, *]
end
Attributes
VarField

the splat on the left-hand side

VarField

the splat on the right-hand side

Array[ Node ]

the list of positional expressions in the pattern that

are being matched

Public Class Methods

Source

def initialize(constant:, left:, values:, right:, location:)
  @constant = constant
  @left = left
  @values = values
  @right = right
  @location = location
  @comments = []
end
Public Instance Methods

Source

def ===(other)
  other.is_a?(FndPtn) && constant === other.constant &&
    left === other.left && ArrayMatch.call(values, other.values) &&
    right === other.right
end

Source

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

Source

def child_nodes
  [constant, left, *values, right]
end

Source

def copy(constant: nil, left: nil, values: nil, right: nil, location: nil)
  node =
    FndPtn.new(
      constant: constant || self.constant,
      left: left || self.left,
      values: values || self.values,
      right: right || self.right,
      location: location || self.location
    )

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

Source

def deconstruct_keys(_keys)
  {
    constant: constant,
    left: left,
    values: values,
    right: right,
    location: location,
    comments: comments
  }
end

Source

def format(q)
  q.format(constant) if constant

  q.group do
    q.text("[")

    q.indent do
      q.breakable_empty

      q.text("*")
      q.format(left)
      q.comma_breakable

      q.seplist(values) { |value| q.format(value) }
      q.comma_breakable

      q.text("*")
      q.format(right)
    end

    q.breakable_empty
    q.text("]")
  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