Class: YARP::EmbeddedStatementsNode

Inherits:
YARPNode
  • Object
show all
Defined in:
lib/yarp/node.rb,
ext/yarp/api_node.c

Overview

Represents an interpolated set of statements.

"foo #{bar}"
     ^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opening_loc, statements, closing_loc, location) ⇒ EmbeddedStatementsNode

def initialize: (opening_loc: Location, statements: StatementsNode?, closing_loc: Location, location: Location) -> void



2665
2666
2667
2668
2669
2670
# File 'lib/yarp/node.rb', line 2665

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_locObject (readonly)

attr_reader closing_loc: Location



2662
2663
2664
# File 'lib/yarp/node.rb', line 2662

def closing_loc
  @closing_loc
end

#opening_locObject (readonly)

attr_reader opening_loc: Location



2656
2657
2658
# File 'lib/yarp/node.rb', line 2656

def opening_loc
  @opening_loc
end

#statementsObject (readonly)

attr_reader statements: StatementsNode?



2659
2660
2661
# File 'lib/yarp/node.rb', line 2659

def statements
  @statements
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



2673
2674
2675
# File 'lib/yarp/node.rb', line 2673

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

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array[nil | Node]



2678
2679
2680
# File 'lib/yarp/node.rb', line 2678

def child_nodes
  [statements]
end

#closingObject

def closing: () -> String



2706
2707
2708
# File 'lib/yarp/node.rb', line 2706

def closing
  closing_loc.slice
end

#copy(**params) ⇒ Object

def copy: (**params) -> EmbeddedStatementsNode



2683
2684
2685
2686
2687
2688
2689
2690
# File 'lib/yarp/node.rb', line 2683

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

def deconstruct_keys: (keys: Array) -> Hash[Symbol, nil | Node | Array | String | Token | Array | Location]



2696
2697
2698
# File 'lib/yarp/node.rb', line 2696

def deconstruct_keys(keys)
  { opening_loc: opening_loc, statements: statements, closing_loc: closing_loc, location: location }
end

#openingObject

def opening: () -> String



2701
2702
2703
# File 'lib/yarp/node.rb', line 2701

def opening
  opening_loc.slice
end