Class: ETL::Parser::FixedWidthField

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

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, field_start, field_end = nil, field_length = nil) ⇒ FixedWidthField

Initialize the field.



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/etl/parser/fixed_width_parser.rb', line 50

def initialize(name, field_start, field_end=nil, field_length=nil)
  @name = name
  @field_start = field_start - 1
  if field_end
    @field_end = field_end
    @field_length = @field_end - @field_start
  elsif field_length
    @field_length = field_length
    @field_end = @field_start + @field_length
  else
    raise DefinitionError, "Either field_end or field_length required"
  end
end

Instance Attribute Details

#field_endObject (readonly)

Returns the value of attribute field_end.



48
49
50
# File 'lib/etl/parser/fixed_width_parser.rb', line 48

def field_end
  @field_end
end

#field_lengthObject (readonly)

Returns the value of attribute field_length.



48
49
50
# File 'lib/etl/parser/fixed_width_parser.rb', line 48

def field_length
  @field_length
end

#field_startObject (readonly)

Returns the value of attribute field_start.



48
49
50
# File 'lib/etl/parser/fixed_width_parser.rb', line 48

def field_start
  @field_start
end

#nameObject (readonly)

Returns the value of attribute name.



48
49
50
# File 'lib/etl/parser/fixed_width_parser.rb', line 48

def name
  @name
end