class Prism::UnlessNode
Represents the use of the unless keyword, either in the block form or the modifier form.
bar unless foo ^^^^^^^^^^^^^^ unless foo then bar end ^^^^^^^^^^^^^^^^^^^^^^^
Represents the use of the unless keyword, either in the block form or the modifier form.
bar unless foo ^^^^^^^^^^^^^^ unless foo then bar end ^^^^^^^^^^^^^^^^^^^^^^^
Public Class Methods
(Source source, Integer node_id, Location location, Integer flags, Location unless_keyword_loc, Prism::node predicate, Location? then_keyword_loc, StatementsNode? statements, ElseNode? else_clause, Location? end_keyword_loc) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 32130 def initialize(source, node_id, location, flags, unless_keyword_loc, predicate, then_keyword_loc, statements, else_clause, end_keyword_loc) @source = source @node_id = node_id @location = location @flags = flags @unless_keyword_loc = unless_keyword_loc @predicate = predicate @then_keyword_loc = then_keyword_loc @statements = statements @else_clause = else_clause @end_keyword_loc = end_keyword_loc end
Initialize a new UnlessNode node.
Initialize a new UnlessNode node.
: (Source source, Integer node_id, Location location, Integer flags, Location unless_keyword_loc, Prism::node predicate, Location? then_keyword_loc, StatementsNode? statements, ElseNode? else_clause, Location? end_keyword_loc) -> void
Public Instance Methods
(untyped other) → boolish
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/sig/generated/prism/node.rbs, line 20636
def ===: (untyped other) -> boolish
: (untyped other) -> boolish
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/sig/generated/prism/node.rbs, line 20475
def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped]
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 32362 def else_clause @else_clause end
The else clause of the unless expression, if present.
unless cond then bar else baz end ^^^^^^^^^^^^
:call-seq: else_clause -> ElseNode | nil
The else clause of the unless expression, if present.
unless cond then bar else baz end ^^^^^^^^^^^^
: () -> ElseNode?
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/sig/generated/prism/node.rbs, line 20488
def inspect: () -> String
: () -> String
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/sig/generated/prism/node_ext.rbs, line 241
def keyword: () -> String
: () -> String
() → Location
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/sig/generated/prism/node_ext.rbs, line 244
def keyword_loc: () -> Location
: () -> Location
(Array[bool] lines) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/sig/generated/prism/parse_result/newlines.rbs, line 131
def newline_flag!: (Array[bool] lines) -> void
: (Array lines) -> void
() → Prism::node
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 32293 def predicate @predicate end
The condition to be evaluated for the unless expression. It can be any non-void expression.
unless cond then bar end ^^^^ bar unless cond ^^^^
:call-seq: predicate -> Node
The condition to be evaluated for the unless expression. It can be any non-void expression.
unless cond then bar end ^^^^ bar unless cond ^^^^
: () -> Prism::node
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 32345 def statements @statements end
The body of statements that will executed if the unless condition is falsey. Will be nil if no body is provided.
unless cond then bar end ^^^
:call-seq: statements -> StatementsNode | nil
The body of statements that will executed if the unless condition is falsey. Will be nil if no body is provided.
unless cond then bar end ^^^
: () -> StatementsNode?
Locations
Public Instance Methods
() → Location?
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 32380 def end_keyword_loc location = @end_keyword_loc case location when nil nil when Location location else @end_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end end
The Location of the end keyword, if present.
unless cond then bar end ^^^
:category: Locations :call-seq: end_keyword_loc -> Location | nil
The Location of the end keyword, if present.
unless cond then bar end ^^^
: () -> Location?
() → Location?
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 32311 def then_keyword_loc location = @then_keyword_loc case location when nil nil when Location location else @then_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end end
The Location of the then keyword, if present.
unless cond then bar end ^^^^
:category: Locations :call-seq: then_keyword_loc -> Location | nil
The Location of the then keyword, if present.
unless cond then bar end ^^^^
: () -> Location?
() → Location
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 32262 def unless_keyword_loc location = @unless_keyword_loc return location if location.is_a?(Location) @unless_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
The Location of the unless keyword.
unless cond then bar end ^^^^^^ bar unless cond ^^^^^^
:category: Locations :call-seq: unless_keyword_loc -> Location
The Location of the unless keyword.
unless cond then bar end ^^^^^^ bar unless cond ^^^^^^
: () -> Location
Node Interface
These methods are present on all subclasses of Node. Read the node interface docs for more information.
Public Class Methods
Public Instance Methods
(_Visitor visitor) → untyped
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 32157 def accept(visitor) visitor.visit_unless_node(self) end
() → Array[node?]
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 32164 def child_nodes [predicate, statements, else_clause] end
() → Array[node]
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 32183 def compact_child_nodes compact = [] #: Array[Prism::node] compact << predicate if (statements = self.statements); compact << statements; end if (else_clause = self.else_clause); compact << else_clause; end compact end
(?node_id: Integer, ?location: Location, ?flags: Integer, ?unless_keyword_loc: Location, ?predicate: Prism::node, ?then_keyword_loc: Location?, ?statements: StatementsNode?, ?else_clause: ElseNode?, ?end_keyword_loc: Location?) → UnlessNode
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 32197 def copy(node_id: self.node_id, location: self.location, flags: self.flags, unless_keyword_loc: self.unless_keyword_loc, predicate: self.predicate, then_keyword_loc: self.then_keyword_loc, statements: self.statements, else_clause: self.else_clause, end_keyword_loc: self.end_keyword_loc) UnlessNode.new(source, node_id, location, flags, unless_keyword_loc, predicate, then_keyword_loc, statements, else_clause, end_keyword_loc) end
Creates a copy of self with the given fields, using self as the template.
:call-seq: copy(**fields) -> UnlessNode
Creates a copy of self with the given fields, using self as the template.
: (?node_id: Integer, ?location: Location, ?flags: Integer, ?unless_keyword_loc: Location, ?predicate: Prism::node, ?then_keyword_loc: Location?, ?statements: StatementsNode?, ?else_clause: ElseNode?, ?end_keyword_loc: Location?) -> UnlessNode
() → Enumerator[node, void]
() { (node) → void } → void
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 32172 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? yield predicate if (statements = self.statements); yield statements; end if (else_clause = self.else_clause); yield else_clause; end end
See Node.each_child_node.
See Node.each_child_node.
: () -> Enumerator[node, void] : () { (node) -> void } -> void
Repository
Methods related to Relocation.
Public Instance Methods
(_Repository repository) → Relocation::Entry?
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 32397 def save_end_keyword_loc(repository) repository.enter(node_id, :end_keyword_loc) unless @end_keyword_loc.nil? end
Save the end_keyword_loc location using the given saved source so that it can be retrieved later.
:category: Repository Save the end_keyword_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry?
(_Repository repository) → Relocation::Entry?
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 32328 def save_then_keyword_loc(repository) repository.enter(node_id, :then_keyword_loc) unless @then_keyword_loc.nil? end
Save the then_keyword_loc location using the given saved source so that it can be retrieved later.
:category: Repository Save the then_keyword_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry?
(_Repository repository) → Relocation::Entry
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 32273 def save_unless_keyword_loc(repository) repository.enter(node_id, :unless_keyword_loc) end
Save the unless_keyword_loc location using the given saved source so that it can be retrieved later.
:category: Repository Save the unless_keyword_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
Slicing
Public Instance Methods
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 32428 def end_keyword end_keyword_loc&.slice end
Slice the location of end_keyword_loc from the source.
:call-seq: end_keyword -> String | nil
Slice the location of end_keyword_loc from the source.
: () -> String?
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 32418 def then_keyword then_keyword_loc&.slice end
Slice the location of then_keyword_loc from the source.
:call-seq: then_keyword -> String | nil
Slice the location of then_keyword_loc from the source.
: () -> String?
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 32408 def unless_keyword unless_keyword_loc.slice end
Slice the location of unless_keyword_loc from the source.
:call-seq: unless_keyword -> String
Slice the location of unless_keyword_loc from the source.
: () -> String