class CnabRb::Format::PictureFormats::Integer
Attributes
length[R]
Public Class Methods
new(length)
click to toggle source
# File lib/cnab_rb/format/picture_formats/integer.rb, line 5 def initialize(length) @length = length end
Public Instance Methods
decode(value)
click to toggle source
# File lib/cnab_rb/format/picture_formats/integer.rb, line 17 def decode(value) value.to_i end
encode(value)
click to toggle source
# File lib/cnab_rb/format/picture_formats/integer.rb, line 9 def encode(value) value = value.to_s.rjust(@length, '0') if value.length > @length raise CnabRb::Error.new("Invalid integer length to #{value}") end value end