Class: YARP::ParenthesesNode

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

Overview

Represents a parenthesized expression

(10 + 34)
^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

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



4632
4633
4634
4635
4636
4637
# File 'lib/yarp/node.rb', line 4632

def initialize(statements, opening_loc, closing_loc, location)
  @statements = statements
  @opening_loc = opening_loc
  @closing_loc = closing_loc
  @location = location
end

Instance Attribute Details

#closing_locObject (readonly)

attr_reader closing_loc: Location



4629
4630
4631
# File 'lib/yarp/node.rb', line 4629

def closing_loc
  @closing_loc
end

#opening_locObject (readonly)

attr_reader opening_loc: Location



4626
4627
4628
# File 'lib/yarp/node.rb', line 4626

def opening_loc
  @opening_loc
end

#statementsObject (readonly)

attr_reader statements: Node?



4623
4624
4625
# File 'lib/yarp/node.rb', line 4623

def statements
  @statements
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



4640
4641
4642
# File 'lib/yarp/node.rb', line 4640

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

#child_nodesObject Also known as: deconstruct

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



4649
4650
4651
# File 'lib/yarp/node.rb', line 4649

def child_nodes
  [statements]
end

#closingObject

def closing: () -> String



4667
4668
4669
# File 'lib/yarp/node.rb', line 4667

def closing
  closing_loc.slice
end

#deconstruct_keys(keys) ⇒ Object

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



4657
4658
4659
# File 'lib/yarp/node.rb', line 4657

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

#openingObject

def opening: () -> String



4662
4663
4664
# File 'lib/yarp/node.rb', line 4662

def opening
  opening_loc.slice
end

#set_newline_flag(newline_marked) ⇒ Object



4644
4645
4646
# File 'lib/yarp/node.rb', line 4644

def set_newline_flag(newline_marked)
  # Never mark ParenthesesNode with a newline flag, mark children instead
end