Class: Roast::SystemCogs::Map::Output
- Inherits:
-
Cog::Output
- Object
- Cog::Output
- Roast::SystemCogs::Map::Output
- Defined in:
- lib/roast/system_cogs/map.rb
Overview
Output from running the map cog
Contains results from each iteration, allowing access to individual iteration outputs.
Iterations that did not run (due to break!) will be nil.
See Also
Roast::CogInputContext#collect- retrieves all iteration outputs as an arrayRoast::CogInputContext#reduce- reduces iteration outputs to a single value
Instance Method Summary collapse
-
#first ⇒ Object
Get the output from the first iteration.
-
#initialize(execution_managers) ⇒ Output
constructor
Initialize the output with results for each iteration.
-
#iteration(index) ⇒ Object
Get the output from a specific iteration, in concert with
from. -
#iteration?(index) ⇒ Boolean
Check if a specific iteration ran successfully.
-
#last ⇒ Object
Get the output from the last iteration that ran.
Constructor Details
Instance Method Details
#first ⇒ Object
Get the output from the first iteration
Convenience method equivalent to iteration(0). Raises MapIterationDidNotRunError
if the first iteration did not run.
See Also
iterationlast
: () -> Call::Output
235 236 237 |
# File 'lib/roast/system_cogs/map.rb', line 235 def first iteration(0) end |
#iteration(index) ⇒ Object
Get the output from a specific iteration, in concert with from
Returns a Roast::SystemCogs::Call::Output object for the iteration at the given index.
Supports negative indices to count from the end (e.g., -1 for the last iteration).
Raises MapIterationDidNotRunError if the iteration did not run.
Use from on the return value of this method, as for a single call cog invocation, to access the
final output and individual cog outputs from the specified invocation.
Usage
# Access a specific iteration
result = from(map!(:process_items).iteration(2))
# Access with negative index
result = from(map!(:process_items).iteration(-1))
See Also
iteration?firstlastRoast::CogInputContext#from
: (Integer) -> Call::Output
218 219 220 221 222 223 |
# File 'lib/roast/system_cogs/map.rb', line 218 def iteration(index) em = @execution_managers.fetch(index) raise MapIterationDidNotRunError, index unless em.present? Call::Output.new(em) end |
#iteration?(index) ⇒ Boolean
Check if a specific iteration ran successfully
Returns true if the iteration at the given index executed, false if it was
skipped (e.g., due to break!). Supports negative indices to count from the end.
See Also
iteration
: (Integer) -> bool
189 190 191 |
# File 'lib/roast/system_cogs/map.rb', line 189 def iteration?(index) @execution_managers.fetch(index).present? end |
#last ⇒ Object
Get the output from the last iteration that ran
Convenience method equivalent to iteration(-1). Raises MapIterationDidNotRunError
if the last iteration did not run.
See Also
iterationfirst
: () -> Call::Output
249 250 251 |
# File 'lib/roast/system_cogs/map.rb', line 249 def last iteration(-1) end |