Class: Grcode::QRCode
- Inherits:
-
Object
- Object
- Grcode::QRCode
- Defined in:
- lib/grcode.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(string, options = {}) ⇒ QRCode
constructor
A new instance of QRCode.
Constructor Details
#initialize(string, options = {}) ⇒ QRCode
Returns a new instance of QRCode.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/grcode.rb', line 5 def initialize(string, ={}) unless string.is_a? String raise "GRCode expected an String, but it found a #{string.class}" end = {} [:cht] = 'qr' # Tell google we want a QRCode [:chl] = string [:chs] = [:size] ? "#{options[:size]}x#{options[:size]}" : '150x150' if [:encoding] [:choe] = [:encoding] end if [:correction] || [:margin] correction = [:correction] || 'L' margin = [:margin] || '4' [:chld] = "#{correction}|#{margin}" end @url = make_url() end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
3 4 5 |
# File 'lib/grcode.rb', line 3 def url @url end |