Class: YARP::BreakNode

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

Overview

Represents the use of the ‘break` keyword.

break foo
^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arguments, keyword_loc, location) ⇒ BreakNode

def initialize: (arguments: Node?, keyword_loc: Location, location: Location) -> void



726
727
728
729
730
# File 'lib/yarp/node.rb', line 726

def initialize(arguments, keyword_loc, location)
  @arguments = arguments
  @keyword_loc = keyword_loc
  @location = location
end

Instance Attribute Details

#argumentsObject (readonly)

attr_reader arguments: Node?



720
721
722
# File 'lib/yarp/node.rb', line 720

def arguments
  @arguments
end

#keyword_locObject (readonly)

attr_reader keyword_loc: Location



723
724
725
# File 'lib/yarp/node.rb', line 723

def keyword_loc
  @keyword_loc
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



733
734
735
# File 'lib/yarp/node.rb', line 733

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

#child_nodesObject Also known as: deconstruct

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



739
740
741
# File 'lib/yarp/node.rb', line 739

def child_nodes
  [arguments]
end

#deconstruct_keys(keys) ⇒ Object

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



747
748
749
# File 'lib/yarp/node.rb', line 747

def deconstruct_keys(keys)
  { arguments: arguments, keyword_loc: keyword_loc, location: location }
end

#keywordObject

def keyword: () -> String



752
753
754
# File 'lib/yarp/node.rb', line 752

def keyword
  keyword_loc.slice
end