Class: FTF::Records::Base
- Inherits:
-
Object
- Object
- FTF::Records::Base
- Defined in:
- lib/ftf/records/base.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Instance Method Summary collapse
- #identifier ⇒ Object
-
#initialize(index, data) ⇒ Base
constructor
A new instance of Base.
- #padding(data, size) ⇒ Object
- #render ⇒ Object
Constructor Details
#initialize(index, data) ⇒ Base
8 9 10 11 |
# File 'lib/ftf/records/base.rb', line 8 def initialize(index, data) @index = index @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/ftf/records/base.rb', line 6 def data @data end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
6 7 8 |
# File 'lib/ftf/records/base.rb', line 6 def index @index end |
Instance Method Details
#identifier ⇒ Object
13 14 15 |
# File 'lib/ftf/records/base.rb', line 13 def identifier raise "Please provide a record identifier" end |
#padding(data, size) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/ftf/records/base.rb', line 17 def padding(data, size) case data when Integer data.to_s.rjust(size, "0") else data.to_s.ljust(size, " ") end end |
#render ⇒ Object
26 27 28 |
# File 'lib/ftf/records/base.rb', line 26 def render { identifier: identifier }.merge(fields).values.join end |