class CnabRb::Format::Picture
Public Class Methods
new(picture)
click to toggle source
# File lib/cnab_rb/format/picture.rb, line 3 def initialize(picture) if match = picture.match(/([X9])\((\d+)\)(V9\((\d+)\))?/) type, length, _, length_decimal = match.captures length = length.to_i unless length_decimal.nil? length_decimal = length_decimal.to_i end if 'X' == type @format = PictureFormats::Text.new(length) elsif ('9' == type and length_decimal.nil?) @format = PictureFormats::Integer.new(length) else @format = PictureFormats::Float.new(length, length_decimal) end else raise CnabRb::Error.new("Invalid picture #{picture}") end end
Public Instance Methods
decode(value)
click to toggle source
# File lib/cnab_rb/format/picture.rb, line 28 def decode(value) @format.decode(value) end
encode(value)
click to toggle source
# File lib/cnab_rb/format/picture.rb, line 24 def encode(value) @format.encode(value) end
length()
click to toggle source
# File lib/cnab_rb/format/picture.rb, line 32 def length @format.length end