Class: YARP::UntilNode

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

Overview

Represents the use of the ‘until` keyword, either in the block form or the modifier form.

bar until foo
^^^^^^^^^^^^^

until foo do bar end
^^^^^^^^^^^^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(keyword_loc, predicate, statements, flags, location) ⇒ UntilNode

def initialize: (keyword_loc: Location, predicate: Node, statements: Node?, flags: Integer, location: Location) -> void



6133
6134
6135
6136
6137
6138
6139
# File 'lib/yarp/node.rb', line 6133

def initialize(keyword_loc, predicate, statements, flags, location)
  @keyword_loc = keyword_loc
  @predicate = predicate
  @statements = statements
  @flags = flags
  @location = location
end

Instance Attribute Details

#flagsObject (readonly)

attr_reader flags: Integer



6130
6131
6132
# File 'lib/yarp/node.rb', line 6130

def flags
  @flags
end

#keyword_locObject (readonly)

attr_reader keyword_loc: Location



6121
6122
6123
# File 'lib/yarp/node.rb', line 6121

def keyword_loc
  @keyword_loc
end

#predicateObject (readonly)

attr_reader predicate: Node



6124
6125
6126
# File 'lib/yarp/node.rb', line 6124

def predicate
  @predicate
end

#statementsObject (readonly)

attr_reader statements: Node?



6127
6128
6129
# File 'lib/yarp/node.rb', line 6127

def statements
  @statements
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



6142
6143
6144
# File 'lib/yarp/node.rb', line 6142

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

#begin_modifier?Boolean

def begin_modifier?: () -> bool

Returns:

  • (Boolean)


6169
6170
6171
# File 'lib/yarp/node.rb', line 6169

def begin_modifier?
  flags.anybits?(LoopFlags::BEGIN_MODIFIER)
end

#child_nodesObject Also known as: deconstruct

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



6151
6152
6153
# File 'lib/yarp/node.rb', line 6151

def child_nodes
  [predicate, statements]
end

#deconstruct_keys(keys) ⇒ Object

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



6159
6160
6161
# File 'lib/yarp/node.rb', line 6159

def deconstruct_keys(keys)
  { keyword_loc: keyword_loc, predicate: predicate, statements: statements, flags: flags, location: location }
end

#keywordObject

def keyword: () -> String



6164
6165
6166
# File 'lib/yarp/node.rb', line 6164

def keyword
  keyword_loc.slice
end

#set_newline_flag(newline_marked) ⇒ Object



6146
6147
6148
# File 'lib/yarp/node.rb', line 6146

def set_newline_flag(newline_marked)
  predicate.set_newline_flag(newline_marked)
end