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.
1929 1930 1931 1932 1933 1934 1935 1936 |
# File 'lib/prism/node.rb', line 1929 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
^^^
1977 1978 1979 |
# File 'lib/prism/node.rb', line 1977 def arguments @arguments end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
2005 2006 2007 |
# File 'lib/prism/node.rb', line 2005 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.
2011 2012 2013 2014 2015 |
# File 'lib/prism/node.rb', line 2011 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
1939 1940 1941 |
# File 'lib/prism/node.rb', line 1939 def accept(visitor) visitor.visit_break_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
1944 1945 1946 |
# File 'lib/prism/node.rb', line 1944 def child_nodes [arguments] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
1956 1957 1958 |
# File 'lib/prism/node.rb', line 1956 def comment_targets [*arguments, keyword_loc] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
1949 1950 1951 1952 1953 |
# File 'lib/prism/node.rb', line 1949 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
1961 1962 1963 |
# File 'lib/prism/node.rb', line 1961 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 }
1969 1970 1971 |
# File 'lib/prism/node.rb', line 1969 def deconstruct_keys(keys) { node_id: node_id, location: location, arguments: arguments, keyword_loc: keyword_loc } end |
#inspect ⇒ Object
def inspect -> String
1995 1996 1997 |
# File 'lib/prism/node.rb', line 1995 def inspect InspectVisitor.compose(self) end |
#keyword ⇒ Object
def keyword: () -> String
1990 1991 1992 |
# File 'lib/prism/node.rb', line 1990 def keyword keyword_loc.slice end |
#keyword_loc ⇒ Object
The location of the ‘break` keyword.
break foo
^^^^^
1983 1984 1985 1986 1987 |
# File 'lib/prism/node.rb', line 1983 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`.
2000 2001 2002 |
# File 'lib/prism/node.rb', line 2000 def type :break_node end |