Class: Hasta::SortedDataSource
- Inherits:
-
Object
- Object
- Hasta::SortedDataSource
- Defined in:
- lib/hasta/sorted_data_source.rb
Overview
Decorator for a data source that yields the contents in sorted order
Instance Method Summary collapse
- #each_line ⇒ Object
-
#initialize(data_source) ⇒ SortedDataSource
constructor
A new instance of SortedDataSource.
- #name ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(data_source) ⇒ SortedDataSource
Returns a new instance of SortedDataSource.
6 7 8 |
# File 'lib/hasta/sorted_data_source.rb', line 6 def initialize(data_source) @data_source = data_source end |
Instance Method Details
#each_line ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/hasta/sorted_data_source.rb', line 14 def each_line return enum_for(:each_line) unless block_given? sorted_lines.each do |line| yield line end end |
#name ⇒ Object
10 11 12 |
# File 'lib/hasta/sorted_data_source.rb', line 10 def name data_source.name end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/hasta/sorted_data_source.rb', line 22 def to_s "#<#{self.class.name}:#{name} size=#{lines.count} lines>" end |