Class: YARP::EmbeddedStatementsNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::EmbeddedStatementsNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents an interpolated set of statements.
"foo #{bar}"
^^^^^^
Instance Attribute Summary collapse
-
#closing_loc ⇒ Object
readonly
attr_reader closing_loc: Location.
-
#opening_loc ⇒ Object
readonly
attr_reader opening_loc: Location.
-
#statements ⇒ Object
readonly
attr_reader statements: StatementsNode?.
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#closing ⇒ Object
def closing: () -> String.
-
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location].
-
#copy(**params) ⇒ Object
def copy: (**params) -> EmbeddedStatementsNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(opening_loc, statements, closing_loc, location) ⇒ EmbeddedStatementsNode
constructor
def initialize: (opening_loc: Location, statements: StatementsNode?, closing_loc: Location, location: Location) -> void.
- #inspect(inspector = NodeInspector.new) ⇒ Object
-
#opening ⇒ Object
def opening: () -> String.
Constructor Details
#initialize(opening_loc, statements, closing_loc, location) ⇒ EmbeddedStatementsNode
def initialize: (opening_loc: Location, statements: StatementsNode?, closing_loc: Location, location: Location) -> void
3740 3741 3742 3743 3744 3745 |
# File 'lib/yarp/node.rb', line 3740 def initialize(opening_loc, statements, closing_loc, location) @opening_loc = opening_loc @statements = statements @closing_loc = closing_loc @location = location end |
Instance Attribute Details
#closing_loc ⇒ Object (readonly)
attr_reader closing_loc: Location
3737 3738 3739 |
# File 'lib/yarp/node.rb', line 3737 def closing_loc @closing_loc end |
#opening_loc ⇒ Object (readonly)
attr_reader opening_loc: Location
3731 3732 3733 |
# File 'lib/yarp/node.rb', line 3731 def opening_loc @opening_loc end |
#statements ⇒ Object (readonly)
attr_reader statements: StatementsNode?
3734 3735 3736 |
# File 'lib/yarp/node.rb', line 3734 def statements @statements end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
3748 3749 3750 |
# File 'lib/yarp/node.rb', line 3748 def accept(visitor) visitor.(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
3753 3754 3755 |
# File 'lib/yarp/node.rb', line 3753 def child_nodes [statements] end |
#closing ⇒ Object
def closing: () -> String
3786 3787 3788 |
# File 'lib/yarp/node.rb', line 3786 def closing closing_loc.slice end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
3758 3759 3760 |
# File 'lib/yarp/node.rb', line 3758 def comment_targets [opening_loc, *statements, closing_loc] end |
#copy(**params) ⇒ Object
def copy: (**params) -> EmbeddedStatementsNode
3763 3764 3765 3766 3767 3768 3769 3770 |
# File 'lib/yarp/node.rb', line 3763 def copy(**params) EmbeddedStatementsNode.new( params.fetch(:opening_loc) { opening_loc }, params.fetch(:statements) { statements }, params.fetch(:closing_loc) { closing_loc }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
3776 3777 3778 |
# File 'lib/yarp/node.rb', line 3776 def deconstruct_keys(keys) { opening_loc: opening_loc, statements: statements, closing_loc: closing_loc, location: location } end |
#inspect(inspector = NodeInspector.new) ⇒ Object
3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 |
# File 'lib/yarp/node.rb', line 3790 def inspect(inspector = NodeInspector.new) inspector << inspector.header(self) inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n" if (statements = self.statements).nil? inspector << "├── statements: ∅\n" else inspector << "├── statements:\n" inspector << statements.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix) end inspector << "└── closing_loc: #{inspector.location(closing_loc)}\n" inspector.to_str end |
#opening ⇒ Object
def opening: () -> String
3781 3782 3783 |
# File 'lib/yarp/node.rb', line 3781 def opening opening_loc.slice end |