Class: Hasta::CombinedDataSource
- Inherits:
-
Object
- Object
- Hasta::CombinedDataSource
- Defined in:
- lib/hasta/combined_data_source.rb
Overview
Combines multiple data sources so they can be iterated over continuously
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #each_line ⇒ Object
-
#initialize(sources, name = nil) ⇒ CombinedDataSource
constructor
A new instance of CombinedDataSource.
- #to_a ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(sources, name = nil) ⇒ CombinedDataSource
Returns a new instance of CombinedDataSource.
8 9 10 11 |
# File 'lib/hasta/combined_data_source.rb', line 8 def initialize(sources, name = nil) @sources = sources @name = name || sources.map(&:name).compact.join(', ') end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/hasta/combined_data_source.rb', line 6 def name @name end |
Instance Method Details
#each_line ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/hasta/combined_data_source.rb', line 13 def each_line return enum_for(:each_line) unless block_given? sources.each do |source| source.each_line do |line| yield line end end end |
#to_a ⇒ Object
23 24 25 |
# File 'lib/hasta/combined_data_source.rb', line 23 def to_a each_line.to_a end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/hasta/combined_data_source.rb', line 27 def to_s "#<#{self.class.name}:#{name}>" end |