lib/etl/parser/fixed_width_parser.rb in activewarehouse-etl-0.6.0 vs lib/etl/parser/fixed_width_parser.rb in activewarehouse-etl-0.6.1
- old
+ new
@@ -20,11 +20,11 @@
if lines_skipped < source.skip_lines
lines_skipped += 1
next
end
# TODO make strip optional?
- row[name] = convert(name, line[f.field_start, f.field_length].strip, f.type)
+ row[name] = line[f.field_start, f.field_length].strip
end
yield row
end
end
end
@@ -35,19 +35,21 @@
end
private
def configure
source.definition.each do |field, options|
- fields[field] = FixedWidthField.new(options[:name], options[:start], options[:end], options[:length], options[:type])
+ fields[field] = FixedWidthField.new(
+ options[:name], options[:start], options[:end], options[:length]
+ )
end
end
end
class FixedWidthField #:nodoc:
- attr_reader :name, :field_start, :field_end, :field_length, :type
- def initialize(name, field_start, field_end=nil, field_length=nil, type=nil)
+ attr_reader :name, :field_start, :field_end, :field_length
+ # Initialize the field.
+ def initialize(name, field_start, field_end=nil, field_length=nil)
@name = name
- @type = type ||= :string
@field_start = field_start - 1
if field_end
@field_end = field_end
@field_length = @field_end - @field_start
elsif field_length
\ No newline at end of file