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

class SyntaxTree::Assoc - RDoc Documentation

  1. SyntaxTree::
  2. Assoc
class SyntaxTree::Assoc

Assoc represents a key-value pair within a hash. It is a child node of either an AssocListFromArgs or a BareAssocHash.

{ key1: value1, key2: value2 }

In the above example, the would be two Assoc nodes.

Attributes
Node

the key of this pair

nil | Node

the value of this pair

Public Class Methods

Source

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

Source

def ===(other)
  other.is_a?(Assoc) && key === other.key && value === other.value
end

Source

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

Source

def child_nodes
  [key, value]
end

Source

def copy(key: nil, value: nil, location: nil)
  node =
    Assoc.new(
      key: key || self.key,
      value: value || self.value,
      location: location || self.location
    )

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

Source

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

Source

def format(q)
  if value.is_a?(HashLiteral)
    format_contents(q)
  else
    q.group { format_contents(q) }
  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