Class: ETL::Parser::Parser

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/etl/parser/parser.rb

Overview

Base parser class. Implementation classes must extend this class and implement the each method. The each method should return each row of the source data as a Hash.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, options = {}) ⇒ Parser

Returns a new instance of Parser.



24
25
26
27
# File 'lib/etl/parser/parser.rb', line 24

def initialize(source, options={})
  @source = source
  @options = options || {}
end

Instance Attribute Details

#optionsObject (readonly)

Options Hash for the parser



22
23
24
# File 'lib/etl/parser/parser.rb', line 22

def options
  @options
end

#sourceObject (readonly)

The Source object for the data



19
20
21
# File 'lib/etl/parser/parser.rb', line 19

def source
  @source
end

Class Method Details

.class_for_name(name) ⇒ Object

Convert the name (string or symbol) to a parser class.

Example:

<tt>class_for_name(:fixed_width)</tt> returns a FixedWidthParser class


13
14
15
# File 'lib/etl/parser/parser.rb', line 13

def class_for_name(name)
  ETL::Parser.const_get("#{name.to_s.camelize}Parser")
end