Class: QrForge::QrData

Inherits:
Object
  • Object
show all
Defined in:
lib/qr_forge/qr_data.rb

Overview

QrData is a wrapper around RQRCodeCore::QRCode that provides a simplified interface for accessing QR code data. We can also add additional data related to the QR code, but not always RQRCodeCore related

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text:, version: 10, level: :h) ⇒ QrData

Returns a new instance of QrData.



13
14
15
16
17
18
# File 'lib/qr_forge/qr_data.rb', line 13

def initialize(text:, version: 10, level: :h)
  qr = ::RQRCodeCore::QRCode.new(text, size: version, level: level)
  @version = qr.version
  @modules = qr.modules.map(&:dup)
  @module_count = @modules.size
end

Instance Attribute Details

#module_countObject (readonly)

Returns the value of attribute module_count.



11
12
13
# File 'lib/qr_forge/qr_data.rb', line 11

def module_count
  @module_count
end

#modulesObject (readonly)

Returns the value of attribute modules.



11
12
13
# File 'lib/qr_forge/qr_data.rb', line 11

def modules
  @modules
end

#quiet_zoneObject (readonly)

Returns the value of attribute quiet_zone.



11
12
13
# File 'lib/qr_forge/qr_data.rb', line 11

def quiet_zone
  @quiet_zone
end

#versionObject (readonly)

Returns the value of attribute version.



11
12
13
# File 'lib/qr_forge/qr_data.rb', line 11

def version
  @version
end