Class: CQR::QRFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/cqr/qr_formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#invertObject 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

#marginObject

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_sObject



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