Class: FutureProof::FutureArray
- Inherits:
-
Object
- Object
- FutureProof::FutureArray
- Includes:
- Enumerable, Exceptionable
- Defined in:
- lib/future_proof/future_array.rb
Overview
FutureArray
should be used to raise exceptions if specific values are exception instances on a direct access with #[], #first, #last, #each, #sort and so on.
Instance Method Summary collapse
-
#[](index) ⇒ Object
Acces
FutureArray
value by index. -
#all ⇒ Object
Array of values.
-
#each ⇒ Object
Iterates through array elements.
-
#initialize(arg) ⇒ FutureArray
constructor
A new instance of FutureArray.
Constructor Details
#initialize(arg) ⇒ FutureArray
Returns a new instance of FutureArray.
10 11 12 |
# File 'lib/future_proof/future_array.rb', line 10 def initialize(arg) @arry = Array.new arg end |
Instance Method Details
#[](index) ⇒ Object
Acces FutureArray
value by index.
15 16 17 |
# File 'lib/future_proof/future_array.rb', line 15 def [](index) raise_or_value @arry[index] end |
#all ⇒ Object
Note:
raises an exception if any value if an exception.
Array of values.
22 23 24 |
# File 'lib/future_proof/future_array.rb', line 22 def all map { |a| a } end |
#each ⇒ Object
Note:
raises an error if any value is an exception.
Iterates through array elements.
35 36 37 |
# File 'lib/future_proof/future_array.rb', line 35 def each @arry.each { |a| yield raise_or_value(a) } end |