Class: ETL::Parser::FixedWidthField
- Inherits:
-
Object
- Object
- ETL::Parser::FixedWidthField
- Defined in:
- lib/etl/parser/fixed_width_parser.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#field_end ⇒ Object
readonly
Returns the value of attribute field_end.
-
#field_length ⇒ Object
readonly
Returns the value of attribute field_length.
-
#field_start ⇒ Object
readonly
Returns the value of attribute field_start.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, field_start, field_end = nil, field_length = nil) ⇒ FixedWidthField
constructor
Initialize the field.
Constructor Details
#initialize(name, field_start, field_end = nil, field_length = nil) ⇒ FixedWidthField
Initialize the field.
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/etl/parser/fixed_width_parser.rb', line 51 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_end ⇒ Object (readonly)
Returns the value of attribute field_end.
49 50 51 |
# File 'lib/etl/parser/fixed_width_parser.rb', line 49 def field_end @field_end end |
#field_length ⇒ Object (readonly)
Returns the value of attribute field_length.
49 50 51 |
# File 'lib/etl/parser/fixed_width_parser.rb', line 49 def field_length @field_length end |
#field_start ⇒ Object (readonly)
Returns the value of attribute field_start.
49 50 51 |
# File 'lib/etl/parser/fixed_width_parser.rb', line 49 def field_start @field_start end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
49 50 51 |
# File 'lib/etl/parser/fixed_width_parser.rb', line 49 def name @name end |