Class: Inferno::ResultCollection
- Inherits:
-
Object
- Object
- Inferno::ResultCollection
- Includes:
- Enumerable
- Defined in:
- lib/inferno/result_collection.rb
Overview
The ResultCollection class is used to manage a collection of Inferno::Entities::Result objects. It provides methods to filter required and optional results, access results by index or by their runnable IDs, and iterate over the collection.
Instance Attribute Summary collapse
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
- #<<(result) ⇒ Object
- #[](key) ⇒ Object
- #each ⇒ Object
-
#initialize(results = []) ⇒ ResultCollection
constructor
A new instance of ResultCollection.
- #optional_results ⇒ Object
- #required_results ⇒ Object
Constructor Details
#initialize(results = []) ⇒ ResultCollection
Returns a new instance of ResultCollection.
38 39 40 |
# File 'lib/inferno/result_collection.rb', line 38 def initialize(results = []) @results = results end |
Instance Attribute Details
#results ⇒ Object (readonly)
Returns the value of attribute results.
36 37 38 |
# File 'lib/inferno/result_collection.rb', line 36 def results @results end |
Instance Method Details
#<<(result) ⇒ Object
46 47 48 49 |
# File 'lib/inferno/result_collection.rb', line 46 def <<(result) (results << result).flatten! self end |
#[](key) ⇒ Object
42 43 44 |
# File 'lib/inferno/result_collection.rb', line 42 def [](key) key.is_a?(Integer) ? results[key] : lookup_by_runnable_id(key) end |
#each ⇒ Object
51 52 53 54 55 56 |
# File 'lib/inferno/result_collection.rb', line 51 def each(&) return to_enum(:each) unless block_given? results.each(&) self end |
#optional_results ⇒ Object
62 63 64 |
# File 'lib/inferno/result_collection.rb', line 62 def optional_results results.select(&:optional?) end |
#required_results ⇒ Object
58 59 60 |
# File 'lib/inferno/result_collection.rb', line 58 def required_results results.select(&:required?) end |