Class: YARP::AliasNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::AliasNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents the use of the ‘alias` keyword.
alias foo bar
^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#keyword_loc ⇒ Object
readonly
attr_reader keyword_loc: Location.
-
#new_name ⇒ Object
readonly
attr_reader new_name: Node.
-
#old_name ⇒ Object
readonly
attr_reader old_name: Node.
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location].
-
#copy(**params) ⇒ Object
def copy: (**params) -> AliasNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(new_name, old_name, keyword_loc, location) ⇒ AliasNode
constructor
def initialize: (new_name: Node, old_name: Node, keyword_loc: Location, location: Location) -> void.
- #inspect(inspector = NodeInspector.new) ⇒ Object
-
#keyword ⇒ Object
def keyword: () -> String.
Constructor Details
#initialize(new_name, old_name, keyword_loc, location) ⇒ AliasNode
def initialize: (new_name: Node, old_name: Node, keyword_loc: Location, location: Location) -> void
24 25 26 27 28 29 |
# File 'lib/yarp/node.rb', line 24 def initialize(new_name, old_name, keyword_loc, location) @new_name = new_name @old_name = old_name @keyword_loc = keyword_loc @location = location end |
Instance Attribute Details
#keyword_loc ⇒ Object (readonly)
attr_reader keyword_loc: Location
21 22 23 |
# File 'lib/yarp/node.rb', line 21 def keyword_loc @keyword_loc end |
#new_name ⇒ Object (readonly)
attr_reader new_name: Node
15 16 17 |
# File 'lib/yarp/node.rb', line 15 def new_name @new_name end |
#old_name ⇒ Object (readonly)
attr_reader old_name: Node
18 19 20 |
# File 'lib/yarp/node.rb', line 18 def old_name @old_name end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
32 33 34 |
# File 'lib/yarp/node.rb', line 32 def accept(visitor) visitor.visit_alias_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
37 38 39 |
# File 'lib/yarp/node.rb', line 37 def child_nodes [new_name, old_name] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
42 43 44 |
# File 'lib/yarp/node.rb', line 42 def comment_targets [new_name, old_name, keyword_loc] end |
#copy(**params) ⇒ Object
def copy: (**params) -> AliasNode
47 48 49 50 51 52 53 54 |
# File 'lib/yarp/node.rb', line 47 def copy(**params) AliasNode.new( params.fetch(:new_name) { new_name }, params.fetch(:old_name) { old_name }, params.fetch(:keyword_loc) { keyword_loc }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
60 61 62 |
# File 'lib/yarp/node.rb', line 60 def deconstruct_keys(keys) { new_name: new_name, old_name: old_name, keyword_loc: keyword_loc, location: location } end |
#inspect(inspector = NodeInspector.new) ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'lib/yarp/node.rb', line 69 def inspect(inspector = NodeInspector.new) inspector << inspector.header(self) inspector << "├── new_name:\n" inspector << inspector.child_node(new_name, "│ ") inspector << "├── old_name:\n" inspector << inspector.child_node(old_name, "│ ") inspector << "└── keyword_loc: #{inspector.location(keyword_loc)}\n" inspector.to_str end |
#keyword ⇒ Object
def keyword: () -> String
65 66 67 |
# File 'lib/yarp/node.rb', line 65 def keyword keyword_loc.slice end |