Class: Hasta::InMemoryDataSource

Inherits:
Object
  • Object
show all
Defined in:
lib/hasta/in_memory_data_source.rb

Overview

Data source for reading data from memory

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (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_lineObject



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_aObject



23
24
25
# File 'lib/hasta/in_memory_data_source.rb', line 23

def to_a
  lines
end

#to_sObject



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