class AvetmissData::Base
Public Class Methods
max_record()
click to toggle source
# File lib/avetmiss_data/base.rb, line 15 def self.max_record file_format.values.map { |(range, _)| range.last }.max end
parse(record)
click to toggle source
# 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)
click to toggle source
# 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
Public Instance Methods
file_format_hash()
click to toggle source
# File lib/avetmiss_data/base.rb, line 4 def file_format_hash self.class.file_format end