Class: Quandl::Format::Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/quandl/format/abstract.rb,
lib/quandl/format/abstract/node.rb

Direct Known Subclasses

Superset

Defined Under Namespace

Classes: Node

Class Method Summary collapse

Class Method Details

.each_line_as_node(interface, &block) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/quandl/format/abstract.rb', line 21

def each_line_as_node(interface, &block)
  # initialize an empty node
  node = self::Node.new( block: block )
  # for each_line of the interface
  interface.each_line do |line|
    # add the line to the node
    node = node.add( line )
  end
  # we're done
  node.close
end

.foreach(interface, &block) ⇒ Object



15
16
17
18
19
# File 'lib/quandl/format/abstract.rb', line 15

def foreach(interface, &block)
  each_line_as_node(interface) do |node|
    call_and_catch_block(node, &block)
  end
end

.load(interface) ⇒ Object



9
10
11
12
13
# File 'lib/quandl/format/abstract.rb', line 9

def load(interface)
  output = []
  foreach(interface){|n| output << n }
  output
end