Class: CQR::QRFormatter
- Inherits:
-
Object
- Object
- CQR::QRFormatter
- Defined in:
- lib/cqr/qr_formatter.rb
Instance Attribute Summary collapse
-
#invert ⇒ Object
(also: #invert?)
Returns the value of attribute invert.
-
#margin ⇒ Object
Returns the value of attribute margin.
Instance Method Summary collapse
-
#initialize(string, margin = 0, invert = true) ⇒ QRFormatter
constructor
A new instance of QRFormatter.
- #to_s ⇒ Object
Constructor Details
#initialize(string, margin = 0, invert = true) ⇒ QRFormatter
Returns a new instance of QRFormatter.
8 9 10 11 12 |
# File 'lib/cqr/qr_formatter.rb', line 8 def initialize(string, margin = 0, invert = true) self.margin = margin self.invert = invert create_qr_code(string) end |
Instance Attribute Details
#invert ⇒ Object Also known as: invert?
Returns the value of attribute invert.
5 6 7 |
# File 'lib/cqr/qr_formatter.rb', line 5 def invert @invert end |
#margin ⇒ Object
Returns the value of attribute margin.
5 6 7 |
# File 'lib/cqr/qr_formatter.rb', line 5 def margin @margin end |
Instance Method Details
#to_s ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/cqr/qr_formatter.rb', line 14 def to_s lines = [] lines << horizontal_margin qrstring.lines.map do |line| lines << "#{prefix}#{vertical_margin}#{line.chomp}#{vertical_margin}" end lines << horizontal_margin lines.join "\n" end |