lib/iso8583/bitmap.rb
# Generate the bytes representing this bitmap.
Generate the bytes representing this bitmap.
Generate the bytes representing this bitmap .
def to_bytes
      if RUBY_ENGINE == 'mruby'
        bitmap_hex = ""
        str = String.new("", encoding: 'ASCII-8BIT')
        self.to_s.chars.reverse.each_with_index do |ch, i|
          str << ch
          next if i == 0
          if (i+1) % 4 == 0
            bitmap_hex << str.reverse.to_i(2).to_s(16)
            str = String.new("", encoding: 'ASCII-8BIT')
          end
        end
        unless str.empty?
          bitmap_hex << str.reverse.to_i(2).to_s(16)
        end
        bitmap_hex.reverse.upcase
      else
        [to_s].pack("B*")
      end
    end
def to_bytes if RUBY_ENGINE == 'mruby' bitmap_hex = "" str = String . new ( "" , encoding : 'ASCII-8BIT' ) self . to_s . chars . reverse . each_with_index do | ch , i | str << ch next if i == 0 if ( i + 1 ) % 4 == 0 bitmap_hex << str . reverse . to_i ( 2 ) . to_s ( 16 ) str = String . new ( "" , encoding : 'ASCII-8BIT' ) end end unless str . empty? bitmap_hex << str . reverse . to_i ( 2 ) . to_s ( 16 ) end bitmap_hex . reverse . upcase else [ to_s ] . pack ( "B*" ) end end
Generate the bytes representing this bitmap.
Generate the bytes representing this bitmap .
# Convert binary to hex, by slicing the binary in 4 bytes chuncks