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

class SyntaxTree::Paren - RDoc Documentation

  1. SyntaxTree::
  2. Paren
class SyntaxTree::Paren

Paren represents using balanced parentheses in a couple places in a Ruby program. In general parentheses can be used anywhere a Ruby expression can be used.

(1 + 2)
Attributes
nil | Node

the expression inside the parentheses

LParen

the left parenthesis that opened this statement

Public Class Methods

Source

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

Source

def ===(other)
  other.is_a?(Paren) && lparen === other.lparen &&
    contents === other.contents
end

Source

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

Source

def child_nodes
  [lparen, contents]
end

Source

def copy(lparen: nil, contents: nil, location: nil)
  node =
    Paren.new(
      lparen: lparen || self.lparen,
      contents: contents || self.contents,
      location: location || self.location
    )

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

Source

def deconstruct_keys(_keys)
  {
    lparen: lparen,
    contents: contents,
    location: location,
    comments: comments
  }
end

Source

def format(q)
  contents = self.contents

  q.group do
    q.format(lparen)

    if contents && (!contents.is_a?(Params) || !contents.empty?)
      q.indent do
        q.breakable_empty
        q.format(contents)
      end
    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