Class: Barby::DataMatrix
- Defined in:
- lib/barby/barcode/data_matrix.rb
Overview
Uses the semacode library (gem install semacode) to encode DataMatrix barcodes
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
Instance Method Summary collapse
- #encoder ⇒ Object
- #encoding ⇒ Object
-
#initialize(data) ⇒ DataMatrix
constructor
A new instance of DataMatrix.
- #semacode? ⇒ Boolean
- #to_s ⇒ Object
Methods inherited from Barcode
#method_missing, #outputter_class_for, #outputter_for, outputters, register_outputter, #two_dimensional?, #valid?
Constructor Details
#initialize(data) ⇒ DataMatrix
Returns a new instance of DataMatrix.
13 14 15 |
# File 'lib/barby/barcode/data_matrix.rb', line 13 def initialize(data) self.data = data end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Barby::Barcode
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
10 11 12 |
# File 'lib/barby/barcode/data_matrix.rb', line 10 def data @data end |
Instance Method Details
#encoder ⇒ Object
23 24 25 |
# File 'lib/barby/barcode/data_matrix.rb', line 23 def encoder @encoder ||= ::DataMatrix::Encoder.new(data) end |
#encoding ⇒ Object
28 29 30 |
# File 'lib/barby/barcode/data_matrix.rb', line 28 def encoding encoder.data.map{|a| a.map{|b| b ? '1' : '0' }.join } end |
#semacode? ⇒ Boolean
33 34 35 36 |
# File 'lib/barby/barcode/data_matrix.rb', line 33 def semacode? #TODO: Not sure if this is right data =~ /^http:\/\// end |
#to_s ⇒ Object
39 40 41 |
# File 'lib/barby/barcode/data_matrix.rb', line 39 def to_s data end |