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

class SyntaxTree::AliasNode - RDoc Documentation

  1. SyntaxTree::
  2. AliasNode
class SyntaxTree::AliasNode

Alias represents the use of the alias keyword with regular arguments (not global variables). The alias keyword is used to make a method respond to another name as well as the current one.

alias aliased_name name

For the example above, in the current context you can now call aliased_name and it will execute the name method. When you’re aliasing two methods, you can either provide bare words (like the example above) or you can provide symbols (note that this includes dynamic symbols like :“left-#{middle}-right”).

Attributes Public Class Methods

Source

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

Source

def ===(other)
  other.is_a?(AliasNode) && left === other.left && right === other.right
end

Source

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

Source

def child_nodes
  [left, right]
end

Source

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

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

Source

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

Source

def format(q)
  keyword = "alias "
  left_argument = AliasArgumentFormatter.new(left)

  q.group do
    q.text(keyword)
    q.format(left_argument, stackable: false)
    q.group do
      q.nest(keyword.length) do
        left_argument.comments.any? ? q.breakable_force : q.breakable_space
        q.format(AliasArgumentFormatter.new(right), stackable: false)
      end
    end
  end
end

Source

def var_alias?
  left.is_a?(GVar)
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