class Prism::AliasMethodNode
Represents the use of the alias keyword to alias a method.
alias foo bar ^^^^^^^^^^^^^
Public Class Methods
Source
# File lib/prism/node.rb, line 494 def initialize(source, node_id, location, flags, new_name, old_name, keyword_loc) @source = source @node_id = node_id @location = location @flags = flags @new_name = new_name @old_name = old_name @keyword_loc = keyword_loc end
Initialize a new AliasMethodNode node.
Public Instance Methods
Source
# File lib/prism/node.rb, line 586 def new_name @new_name end
Represents the new name of the method that will be aliased.
alias foo bar
^^^
alias :foo :bar
^^^^
alias :"#{foo}" :"#{bar}"
^^^^^^^^^
Source
# File lib/prism/node.rb, line 603 def old_name @old_name end
Represents the old name of the method that will be aliased.
alias foo bar
^^^
alias :foo :bar
^^^^
alias :"#{foo}" :"#{bar}"
^^^^^^^^^
Locations
Public Instance Methods
Source
# File lib/prism/node.rb, line 615 def keyword_loc location = @keyword_loc return location if location.is_a?(Location) @keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
Represents the Location of the alias keyword.
alias foo bar ^^^^^
Node Interface
Public Class Methods
Public Instance Methods
Source
# File lib/prism/node.rb, line 516 def accept(visitor) visitor.visit_alias_method_node(self) end
See Node.accept.
Source
# File lib/prism/node.rb, line 521 def child_nodes [new_name, old_name] end
See Node.child_nodes.
Also aliased as: deconstruct
Source
# File lib/prism/node.rb, line 539 def comment_targets [new_name, old_name, keyword_loc] #: Array[Prism::node | Location] end
See Node.comment_targets.
Source
# File lib/prism/node.rb, line 534 def compact_child_nodes [new_name, old_name] end
Source
# File lib/prism/node.rb, line 547 def copy(node_id: self.node_id, location: self.location, flags: self.flags, new_name: self.new_name, old_name: self.old_name, keyword_loc: self.keyword_loc) AliasMethodNode.new(source, node_id, location, flags, new_name, old_name, keyword_loc) end
Creates a copy of self with the given fields, using self as the template.
Source
# File lib/prism/node.rb, line 526 def each_child_node return to_enum(:each_child_node) unless block_given? yield new_name yield old_name end
See Node.each_child_node.
Repository
Public Instance Methods
Source
# File lib/prism/node.rb, line 624 def save_keyword_loc(repository) repository.enter(node_id, :keyword_loc) end
Save the keyword_loc location using the given saved source so that it can be retrieved later.
Slicing
Public Instance Methods
Source
# File lib/prism/node.rb, line 634 def keyword keyword_loc.slice end
Slice the location of keyword_loc from the source.