Class: Hasta::InMemoryDataSource
- Inherits:
-
Object
- Object
- Hasta::InMemoryDataSource
- Defined in:
- lib/hasta/in_memory_data_source.rb
Overview
Data source for reading data from memory
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #each_line ⇒ Object
-
#initialize(lines, name = nil) ⇒ InMemoryDataSource
constructor
A new instance of InMemoryDataSource.
- #to_a ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(lines, name = nil) ⇒ InMemoryDataSource
Returns a new instance of InMemoryDataSource.
10 11 12 13 |
# File 'lib/hasta/in_memory_data_source.rb', line 10 def initialize(lines, name=nil) @lines = lines @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/hasta/in_memory_data_source.rb', line 8 def name @name end |
Instance Method Details
#each_line ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/hasta/in_memory_data_source.rb', line 15 def each_line return enum_for(:each_line) unless block_given? lines.each do |line| yield line end end |
#to_a ⇒ Object
23 24 25 |
# File 'lib/hasta/in_memory_data_source.rb', line 23 def to_a lines end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/hasta/in_memory_data_source.rb', line 27 def to_s "#<#{self.class.name}:#{name} size=#{lines.count} lines>" end |