Class: RQRCodePNG::Sequence
- Inherits:
-
Object
- Object
- RQRCodePNG::Sequence
- Defined in:
- lib/rqrcode_png/sequence.rb
Instance Method Summary collapse
-
#border_width ⇒ Object
Returns the border, 1/10 of the img size.
-
#dark_squares_only(&block) ⇒ Object
This method yields the vertices of the dark squares.
-
#img_size ⇒ Object
returns the image size by looking at how long the first line of the code is.
-
#initialize(qr_code) ⇒ Sequence
constructor
A new instance of Sequence.
Constructor Details
#initialize(qr_code) ⇒ Sequence
Returns a new instance of Sequence.
3 4 5 |
# File 'lib/rqrcode_png/sequence.rb', line 3 def initialize(qr_code) @qr_code = qr_code end |
Instance Method Details
#border_width ⇒ Object
Returns the border, 1/10 of the img size
24 25 26 |
# File 'lib/rqrcode_png/sequence.rb', line 24 def border_width() @border ||= img_size() / 10 end |
#dark_squares_only(&block) ⇒ Object
This method yields the vertices of the dark squares
8 9 10 11 12 13 14 15 16 |
# File 'lib/rqrcode_png/sequence.rb', line 8 def dark_squares_only(&block) @qr_code.modules.each_index do |row| @qr_code.modules.each_index do |column| if @qr_code.dark?(row, column) yield row, column end end end end |
#img_size ⇒ Object
returns the image size by looking at how long the first line of the code is
19 20 21 |
# File 'lib/rqrcode_png/sequence.rb', line 19 def img_size @img_size ||= @qr_code.to_s.split("\n").first.size() end |