Class: DataImp::Parser::Stream

Inherits:
DataImp::Parser show all
Defined in:
lib/data_imp/parser/stream.rb

Direct Known Subclasses

Json, Yaml

Instance Attribute Summary

Attributes inherited from DataImp::Parser

#filename

Instance Method Summary collapse

Methods inherited from DataImp::Parser

find_parser, #initialize, #parse, #process_file

Constructor Details

This class inherits a constructor from DataImp::Parser

Instance Method Details

#process(input) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/data_imp/parser/stream.rb', line 2

def process input
  if input.respond_to? :read
    input = input.read
  end
  data = process_string(input)
  case data
  when Hash
    yield data, 0
  when Array
    data.each_with_index do |node, index|
      yield node, index
    end
  end
end