Class: QREncoder::PNG
- Inherits:
-
Object
- Object
- QREncoder::PNG
- Defined in:
- lib/qrencoder/png.rb
Instance Attribute Summary collapse
-
#background ⇒ Object
readonly
Returns the value of attribute background.
-
#canvas ⇒ Object
readonly
Returns the value of attribute canvas.
-
#margin ⇒ Object
readonly
Returns the value of attribute margin.
-
#pixels_per_module ⇒ Object
readonly
Returns the value of attribute pixels_per_module.
-
#points ⇒ Object
readonly
Returns the value of attribute points.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(qrcode, options = {}) ⇒ PNG
constructor
Takes an optional hash of options.
- #method_missing(method, *args, &block) ⇒ Object
- #respond_to?(method) ⇒ Boolean
Constructor Details
#initialize(qrcode, options = {}) ⇒ PNG
Takes an optional hash of options. See QRCode#png for details.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/qrencoder/png.rb', line 14 def initialize(qrcode, ={}) @points = qrcode.points @margin = [:margin] || 4 @pixels_per_module= [:pixels_per_module] || 1 @background = [:transparent] ? ChunkyPNG::Color::TRANSPARENT : ChunkyPNG::Color::WHITE @width = (qrcode.width + (2 * margin)) * pixels_per_module @canvas = ChunkyPNG::Image.new(width, width, background) plot_points end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/qrencoder/png.rb', line 25 def method_missing(method, *args, &block) if canvas.respond_to?(method) canvas.send(method, *args, &block) else super end end |
Instance Attribute Details
#background ⇒ Object (readonly)
Returns the value of attribute background.
5 6 7 |
# File 'lib/qrencoder/png.rb', line 5 def background @background end |
#canvas ⇒ Object (readonly)
Returns the value of attribute canvas.
5 6 7 |
# File 'lib/qrencoder/png.rb', line 5 def canvas @canvas end |
#margin ⇒ Object (readonly)
Returns the value of attribute margin.
5 6 7 |
# File 'lib/qrencoder/png.rb', line 5 def margin @margin end |
#pixels_per_module ⇒ Object (readonly)
Returns the value of attribute pixels_per_module.
5 6 7 |
# File 'lib/qrencoder/png.rb', line 5 def pixels_per_module @pixels_per_module end |
#points ⇒ Object (readonly)
Returns the value of attribute points.
5 6 7 |
# File 'lib/qrencoder/png.rb', line 5 def points @points end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
5 6 7 |
# File 'lib/qrencoder/png.rb', line 5 def width @width end |
Instance Method Details
#respond_to?(method) ⇒ Boolean
33 34 35 |
# File 'lib/qrencoder/png.rb', line 33 def respond_to?(method) super || canvas.respond_to?(method) end |