Class: Prism::BreakNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::BreakNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
Represents the use of the ‘break` keyword.
break foo
^^^^^^^^^
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
The arguments to the break statement, if present.
Class Method Summary collapse
-
.type ⇒ Object
Return a symbol representation of this node type.
Instance Method Summary collapse
-
#===(other) ⇒ Object
Implements case-equality for the node.
-
#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].
-
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array.
-
#copy(node_id: self.node_id, location: self.location, flags: self.flags, arguments: self.arguments, keyword_loc: self.keyword_loc) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?arguments: ArgumentsNode?, ?keyword_loc: Location) -> BreakNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, arguments: ArgumentsNode?, keyword_loc: Location }.
-
#initialize(source, node_id, location, flags, arguments, keyword_loc) ⇒ BreakNode
constructor
Initialize a new BreakNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#keyword ⇒ Object
def keyword: () -> String.
-
#keyword_loc ⇒ Object
The location of the ‘break` keyword.
-
#type ⇒ Object
Return a symbol representation of this node type.
Constructor Details
#initialize(source, node_id, location, flags, arguments, keyword_loc) ⇒ BreakNode
Initialize a new BreakNode node.
1966 1967 1968 1969 1970 1971 1972 1973 |
# File 'lib/prism/node.rb', line 1966 def initialize(source, node_id, location, flags, arguments, keyword_loc) @source = source @node_id = node_id @location = location @flags = flags @arguments = arguments @keyword_loc = keyword_loc end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
The arguments to the break statement, if present. These can be any [non-void expressions](github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
break foo
^^^
2014 2015 2016 |
# File 'lib/prism/node.rb', line 2014 def arguments @arguments end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
2042 2043 2044 |
# File 'lib/prism/node.rb', line 2042 def self.type :break_node end |
Instance Method Details
#===(other) ⇒ Object
Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.
2048 2049 2050 2051 2052 |
# File 'lib/prism/node.rb', line 2048 def ===(other) other.is_a?(BreakNode) && (arguments === other.arguments) && (keyword_loc.nil? == other.keyword_loc.nil?) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
1976 1977 1978 |
# File 'lib/prism/node.rb', line 1976 def accept(visitor) visitor.visit_break_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
1981 1982 1983 |
# File 'lib/prism/node.rb', line 1981 def child_nodes [arguments] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
1993 1994 1995 |
# File 'lib/prism/node.rb', line 1993 def comment_targets [*arguments, keyword_loc] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
1986 1987 1988 1989 1990 |
# File 'lib/prism/node.rb', line 1986 def compact_child_nodes compact = [] #: Array[Prism::node] compact << arguments if arguments compact end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, arguments: self.arguments, keyword_loc: self.keyword_loc) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?arguments: ArgumentsNode?, ?keyword_loc: Location) -> BreakNode
1998 1999 2000 |
# File 'lib/prism/node.rb', line 1998 def copy(node_id: self.node_id, location: self.location, flags: self.flags, arguments: self.arguments, keyword_loc: self.keyword_loc) BreakNode.new(source, node_id, location, flags, arguments, keyword_loc) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, arguments: ArgumentsNode?, keyword_loc: Location }
2006 2007 2008 |
# File 'lib/prism/node.rb', line 2006 def deconstruct_keys(keys) { node_id: node_id, location: location, arguments: arguments, keyword_loc: keyword_loc } end |
#inspect ⇒ Object
def inspect -> String
2032 2033 2034 |
# File 'lib/prism/node.rb', line 2032 def inspect InspectVisitor.compose(self) end |
#keyword ⇒ Object
def keyword: () -> String
2027 2028 2029 |
# File 'lib/prism/node.rb', line 2027 def keyword keyword_loc.slice end |
#keyword_loc ⇒ Object
The location of the ‘break` keyword.
break foo
^^^^^
2020 2021 2022 2023 2024 |
# File 'lib/prism/node.rb', line 2020 def keyword_loc location = @keyword_loc return location if location.is_a?(Location) @keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
2037 2038 2039 |
# File 'lib/prism/node.rb', line 2037 def type :break_node end |