Class: Rjq::Runtime::InputQueue
- Inherits:
-
Object
- Object
- Rjq::Runtime::InputQueue
- Defined in:
- lib/rjq/runtime.rb
Constant Summary collapse
- END_OF_INPUT =
Object.new.freeze
Instance Attribute Summary collapse
-
#current_record ⇒ Object
readonly
Returns the value of attribute current_record.
Instance Method Summary collapse
- #each_remaining ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(records) ⇒ InputQueue
constructor
A new instance of InputQueue.
- #remaining_values ⇒ Object
- #shift ⇒ Object
- #shift_record ⇒ Object
Constructor Details
#initialize(records) ⇒ InputQueue
Returns a new instance of InputQueue.
152 153 154 155 156 |
# File 'lib/rjq/runtime.rb', line 152 def initialize(records) @records = records.to_enum @next_record = nil @current_record = nil end |
Instance Attribute Details
#current_record ⇒ Object (readonly)
Returns the value of attribute current_record.
150 151 152 |
# File 'lib/rjq/runtime.rb', line 150 def current_record @current_record end |
Instance Method Details
#each_remaining ⇒ Object
174 175 176 177 178 |
# File 'lib/rjq/runtime.rb', line 174 def each_remaining return enum_for(:each_remaining) unless block_given? yield shift until empty? end |
#empty? ⇒ Boolean
158 159 160 |
# File 'lib/rjq/runtime.rb', line 158 def empty? peek.equal?(END_OF_INPUT) end |
#remaining_values ⇒ Object
180 181 182 |
# File 'lib/rjq/runtime.rb', line 180 def remaining_values each_remaining.to_a end |
#shift ⇒ Object
170 171 172 |
# File 'lib/rjq/runtime.rb', line 170 def shift shift_record&.value end |
#shift_record ⇒ Object
162 163 164 165 166 167 168 |
# File 'lib/rjq/runtime.rb', line 162 def shift_record record = peek return if record.equal?(END_OF_INPUT) @next_record = nil @current_record = record end |