Class: AsciiDataRow
- Inherits:
-
Object
- Object
- AsciiDataRow
- Defined in:
- lib/ascii_data_row.rb
Class Attribute Summary collapse
-
.fields_definitions ⇒ Object
readonly
Returns the value of attribute fields_definitions.
Class Method Summary collapse
Instance Method Summary collapse
- #fields ⇒ Object
-
#initialize(ascii_row) ⇒ AsciiDataRow
constructor
A new instance of AsciiDataRow.
Constructor Details
#initialize(ascii_row) ⇒ AsciiDataRow
Returns a new instance of AsciiDataRow.
22 23 24 25 26 27 28 |
# File 'lib/ascii_data_row.rb', line 22 def initialize(ascii_row) @fields = {} @ascii_row = remove_invalid_utf8_bytes(ascii_row) self.class.fields_definitions.each_pair do |name, definition| @fields[name] = get_value_for_field_definition(definition) end end |
Class Attribute Details
.fields_definitions ⇒ Object (readonly)
Returns the value of attribute fields_definitions.
6 7 8 |
# File 'lib/ascii_data_row.rb', line 6 def fields_definitions @fields_definitions end |
Class Method Details
.create_from(ascii_row) ⇒ Object
18 19 20 |
# File 'lib/ascii_data_row.rb', line 18 def self.create_from(ascii_row) self.new(ascii_row) end |
.field(name, range, type, options = {}) ⇒ Object
13 14 15 16 |
# File 'lib/ascii_data_row.rb', line 13 def self.field(name, range, type, ={}) [:format] ||= '%d/%m/%Y' fields_definitions[name] = FieldDefinition.new(type, range, ) end |
Instance Method Details
#fields ⇒ Object
30 31 32 |
# File 'lib/ascii_data_row.rb', line 30 def fields @fields end |