Module: TxtData::TxtDataRowDSL

Extended by:
ActiveSupport::Autoload, ActiveSupport::Concern
Included in:
UOB::Payroll::TXTFile::Footer, UOB::Payroll::TXTFile::Header, UOB::Payroll::TXTFile::Row
Defined in:
lib/txt_data/txt_data_row_dsl.rb,
lib/txt_data/txt_data_row_dsl/field.rb

Overview

DSL for defining a class which gives you back a row of a txt data file. class MyTxtRow

include TxtData::TxtDataRowDSL
text :date, 1..6
spaces 7..51
number :my_number, 52..55
text :my_text, 56..58
text :my_fixed_text, 58..71, value: '1234'

def date
  '151201'
end

def my_number
  12
end

def my_text
  "barf"
end

end Use #text to define some text, it is by default left padded with spaces Use #number fo define a number, it is by default left padded with zeroes Use #spaces to add spaces in that field.

Defined Under Namespace

Classes: Field

Instance Method Summary collapse

Instance Method Details

#to_sObject



73
74
75
76
77
# File 'lib/txt_data/txt_data_row_dsl.rb', line 73

def to_s
  self.class.fields.map { |field|
    field.to_s(self)
  }.join("")
end