Class: ArcFurnace::EnumeratorSource
- Defined in:
- lib/arc-furnace/enumerator_source.rb
Direct Known Subclasses
ArraySource, CSVSource, ExcelSource, HashSource, SalsifyJSONSource
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from Node
#error_handler, #node_id, #params
Instance Method Summary collapse
- #advance ⇒ Object
-
#empty? ⇒ Boolean
Is this source empty?.
-
#initialize ⇒ EnumeratorSource
constructor
A new instance of EnumeratorSource.
-
#preprocess ⇒ Object
Called after setting up the enumerator but before advancing it Use this to extract header rows for instance.
Methods inherited from Source
#close, #finalize, #prepare, #row
Constructor Details
#initialize ⇒ EnumeratorSource
Returns a new instance of EnumeratorSource.
9 10 11 12 13 |
# File 'lib/arc-furnace/enumerator_source.rb', line 9 def initialize @enumerator = build_enumerator preprocess advance end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
7 8 9 |
# File 'lib/arc-furnace/enumerator_source.rb', line 7 def value @value end |
Instance Method Details
#advance ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/arc-furnace/enumerator_source.rb', line 26 def advance @value = begin enumerator.next if enumerator rescue StopIteration @enumerator = nil nil end end |
#empty? ⇒ Boolean
Is this source empty?
22 23 24 |
# File 'lib/arc-furnace/enumerator_source.rb', line 22 def empty? !value end |
#preprocess ⇒ Object
Called after setting up the enumerator but before advancing it Use this to extract header rows for instance.
17 18 19 |
# File 'lib/arc-furnace/enumerator_source.rb', line 17 def preprocess # nothing end |