Class RQRCode::QRPolynomial
In: lib/rqrcode/qrcode/qr_polynomial.rb
Parent: Object
RuntimeError QRCodeRunTimeError ArgumentError QRCodeArgumentError QRBitBuffer QR8bitByte QRMath QRRSBlock QRUtil QRPolynomial QRCode lib/rqrcode/qrcode/qr_bit_buffer.rb lib/rqrcode/qrcode/qr_8bit_byte.rb lib/rqrcode/qrcode/qr_math.rb lib/rqrcode/qrcode/qr_rs_block.rb lib/rqrcode/qrcode/qr_util.rb lib/rqrcode/qrcode/qr_polynomial.rb lib/rqrcode/qrcode/qr_code.rb RQRCode dot/m_11_0.png

Methods

get   get_length   mod   multiply   new  

Public Class methods

[Source]

    # File lib/rqrcode/qrcode/qr_polynomial.rb, line 16
16:     def initialize( num, shift )
17:       raise QRCodeRunTimeError, "#{num.size}/#{shift}" if num.empty?
18:       offset = 0
19: 
20:       while offset < num.size && num[offset] == 0
21:         offset = offset + 1
22:       end
23: 
24:       @num = Array.new( num.size - offset + shift )
25: 
26:       ( 0...num.size - offset ).each do |i|
27:         @num[i] = num[i + offset]
28:       end 
29:     end

Public Instance methods

[Source]

    # File lib/rqrcode/qrcode/qr_polynomial.rb, line 32
32:     def get( index )
33:       @num[index]
34:     end

[Source]

    # File lib/rqrcode/qrcode/qr_polynomial.rb, line 37
37:     def get_length
38:       @num.size
39:     end

[Source]

    # File lib/rqrcode/qrcode/qr_polynomial.rb, line 56
56:     def mod( e )
57:       if get_length - e.get_length < 0
58:         return self
59:       end
60: 
61:       ratio = QRMath.glog(get(0)) - QRMath.glog(e.get(0))
62:       num = Array.new(get_length)
63: 
64:       ( 0...get_length ).each do |i|
65:         num[i] = get(i)
66:       end  
67: 
68:       ( 0...e.get_length ).each do |i|
69:         tmp = num[i].nil? ? 0 : num[i]
70:         num[i] = tmp ^ QRMath.gexp(QRMath.glog(e.get(i)) + ratio)
71:       end
72: 
73:       return QRPolynomial.new( num, 0 ).mod(e)
74:     end

[Source]

    # File lib/rqrcode/qrcode/qr_polynomial.rb, line 42
42:     def multiply( e )
43:       num = Array.new( get_length + e.get_length - 1 )
44: 
45:       ( 0...get_length ).each do |i|
46:         ( 0...e.get_length ).each do |j|
47:           tmp = num[i + j].nil? ? 0 : num[i + j]
48:           num[i + j] = tmp ^ QRMath.gexp(QRMath.glog( get(i) ) + QRMath.glog(e.get(j)))
49:         end
50:       end
51: 
52:       return QRPolynomial.new( num, 0 )
53:     end

[Validate]