Sha256: 8cc1a0e9faf3b8c01138b446ed45df804a6b81f42bcec6fe1c11ef16d1e49c6d

Contents?: true

Size: 547 Bytes

Versions: 4

Compression:

Stored size: 547 Bytes

Contents

module BankgiroInbetalningar
  class BgmaxLine
    class << self
      attr_reader :parsers
      def inherited(klass)
        lead = klass.name[/\d+/]
        (@parsers ||= {})[lead] = klass
      end

      def field(name, position, format)
        define_method name do
          value = " #{@line}"[position]
          case format
          when 'N:h0', 'N:-'
            value.sub(/^0+/,'').to_i
          else
            value.strip
          end
        end
      end
    end

    def initialize(line)
      @line = line
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bankgiro_inbetalningar-1.2.0 lib/bankgiro_inbetalningar/bgmax_line.rb
bankgiro_inbetalningar-1.1.1 lib/bankgiro_inbetalningar/bgmax_line.rb
bankgiro_inbetalningar-1.1.0 lib/bankgiro_inbetalningar/bgmax_line.rb
bankgiro_inbetalningar-1.0.0 lib/bankgiro_inbetalningar/bgmax_line.rb