Class: CsvReader::ParserTab

Inherits:
Object
  • Object
show all
Defined in:
lib/csvreader/parser_tab.rb

Instance Method Summary collapse

Instance Method Details

#parse(data, **kwargs, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/csvreader/parser_tab.rb', line 7

def parse( data, **kwargs, &block )

  ## note: input: required each_line (string or io/file for example)
  ## note: kwargs NOT used for now (but required for "protocol/interface" by other parsers)

  input = data   ## assume it's a string or io/file handle

  if block_given?
    parse_lines( input, &block )
  else
    records = []

    parse_lines( input ) do |record|
      records << record
    end

    records
  end
end