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”).
def initialize(left:, right:, location:) @left = left @right = right @location = location @comments = [] endPublic Instance Methods Source
def ===(other) other.is_a?(AliasNode) && left === other.left && right === other.right endSource
def accept(visitor) visitor.visit_alias(self) endSource
def child_nodes [left, right] endSource
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 endSource
def deconstruct_keys(_keys) { left: left, right: right, location: location, comments: comments } endSource
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 endSource
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