Class: SimpleEtl::Source::FixedWidth::Context

Inherits:
BaseContext
  • Object
show all
Defined in:
lib/simple_etl/source/fixed_width/context.rb

Instance Attribute Summary

Attributes inherited from BaseContext

#fields, #generators, #row_count_to_skip, #transformations

Instance Method Summary collapse

Methods inherited from BaseContext

#generate, #initialize, #method_missing, #skip_rows, #transform

Constructor Details

This class inherits a constructor from SimpleEtl::Source::BaseContext

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class SimpleEtl::Source::BaseContext

Instance Method Details

#field(name, start, length, args = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/simple_etl/source/fixed_width/context.rb', line 5

def field name, start, length, args = {}
  raise(FieldArgumentError.new "#{name}::start required") unless start
  raise(FieldArgumentError.new "#{name}::length required") unless length
  start = Integer(start) rescue
    raise(FieldArgumentError.new "#{name}::start (#{start}) is not integer")
  if length != :eol
    length = Integer(length) rescue
      raise(FieldArgumentError.new "#{name}::length (#{length}) is not integer")
  end
  super name, { :start => start, :length => length }.merge(args)
end