Class: AvetmissData::Base
- Inherits:
-
Object
- Object
- AvetmissData::Base
show all
- Defined in:
- lib/avetmiss_data/base.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.max_record ⇒ Object
15
16
17
|
# File 'lib/avetmiss_data/base.rb', line 15
def self.max_record
file_format.values.map { |(range, _)| range.last }.max
end
|
.parse(record) ⇒ Object
8
9
10
11
12
13
|
# File 'lib/avetmiss_data/base.rb', line 8
def self.parse(record)
Hash[file_format.map do |attr, range|
value = record[range].try(:strip)
[attr, value]
end]
end
|
.to_record(values) ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/avetmiss_data/base.rb', line 19
def self.to_record(values)
str = ' ' * max_record
file_format.each_pair do |attr, (range, _)|
str[range] = values[attr].to_s.ljust(range.last - range.first, ' ')
end
str
end
|
Instance Method Details
4
5
6
|
# File 'lib/avetmiss_data/base.rb', line 4
def file_format_hash
self.class.file_format
end
|