Sha256: 3c4a3850707d1f1ffbe2158fef478813f5cad16ba830f162bdc8f39f4b4aff54

Contents?: true

Size: 1.09 KB

Versions: 39

Compression:

Stored size: 1.09 KB

Contents

#!/usr/bin/env ruby

#--
# Copyright 2004 by Duncan Robertson (duncan@whomwah.com).
# All rights reserved.

# Permission is granted for use, copying, modification, distribution,
# and distribution of modified versions of this work as long as the
# above copyright notice is included.
#++

module RQRCode #:nodoc:

  class QRMath

    module_eval { 
      exp_table = Array.new(256)
      log_table = Array.new(256)

      ( 0...8 ).each do |i|
        exp_table[i] = 1 << i
      end

      ( 8...256 ).each do |i|
        exp_table[i] = exp_table[i - 4] \
          ^ exp_table[i - 5] \
          ^ exp_table[i - 6] \
          ^ exp_table[i - 8]
      end

      ( 0...255 ).each do |i|
        log_table[exp_table[i] ] = i
      end

      EXP_TABLE = exp_table 
      LOG_TABLE = log_table 
    }

    class << self

      def glog(n)
        raise QRCodeRunTimeError, "glog(#{n})" if ( n < 1 )
        LOG_TABLE[n]
      end


      def gexp(n)
        while n < 0
          n = n + 255
        end

        while n >= 256
          n = n - 255
        end

        EXP_TABLE[n]
      end

    end

  end

end

Version data entries

39 entries across 39 versions & 7 rubygems

Version Path
second_step-0.1.2 secondstep-notify-1.0.0-osx/lib/ruby/lib/ruby/gems/2.2.0/gems/rqrcode-0.10.1/lib/rqrcode/qrcode/qr_math.rb
oshpark-rqrcode-0.10.2 lib/rqrcode/qrcode/qr_math.rb
oshpark-rqrcode-0.10.1 lib/rqrcode/qrcode/qr_math.rb
rqrcode-0.10.1 lib/rqrcode/qrcode/qr_math.rb
rqrcode-0.10.0 lib/rqrcode/qrcode/qr_math.rb
rqrcode-0.8.2 lib/rqrcode/qrcode/qr_math.rb
rqrcode-0.9.0 lib/rqrcode/qrcode/qr_math.rb
rqrcode-0.8.1 lib/rqrcode/qrcode/qr_math.rb
rqrcode-0.8.0 lib/rqrcode/qrcode/qr_math.rb
rqrcode-0.7.0 lib/rqrcode/qrcode/qr_math.rb
rqrcode-0.6.0 lib/rqrcode/qrcode/qr_math.rb
rqrcode-with-patches-0.6.0 lib/rqrcode/qrcode/qr_math.rb
rqrcode-with-patches-0.5.5 lib/rqrcode/qrcode/qr_math.rb
rqrcode-with-patches-0.5.4 lib/rqrcode/qrcode/qr_math.rb
rqrcode-with-patches-0.5.3 lib/rqrcode/qrcode/qr_math.rb
rqrcode-with-patches-0.5.2 lib/rqrcode/qrcode/qr_math.rb
rqrcode-with-patches-0.5.1 lib/rqrcode/qrcode/qr_math.rb
arena_barby-0.3.2 vendor/rqrcode/lib/rqrcode/qrcode/qr_math.rb
barby-chunky_png-0.3.4 vendor/rqrcode/lib/rqrcode/qrcode/qr_math.rb
rqrcode-0.4.2 lib/rqrcode/qrcode/qr_math.rb