Class: Zebra::Zpl::Datamatrix

Inherits:
Object
  • Object
show all
Includes:
Printable
Defined in:
lib/zebra/zpl/datamatrix.rb

Defined Under Namespace

Classes: InvalidFormatError, InvalidOrientationError, InvalidQualityFactorError, InvalidRatioError, InvalidSizeError

Instance Attribute Summary collapse

Attributes included from Printable

#data, #margin, #position, #x, #y

Instance Method Summary collapse

Methods included from Printable

#initialize, #justification, #justification=, #rotation, #rotation=

Instance Attribute Details

#aspect_ratioObject

Returns the value of attribute aspect_ratio.



14
15
16
# File 'lib/zebra/zpl/datamatrix.rb', line 14

def aspect_ratio
  @aspect_ratio
end

#columnsObject

Returns the value of attribute columns.



14
15
16
# File 'lib/zebra/zpl/datamatrix.rb', line 14

def columns
  @columns
end

#escape_sequenceObject

Returns the value of attribute escape_sequence.



15
16
17
# File 'lib/zebra/zpl/datamatrix.rb', line 15

def escape_sequence
  @escape_sequence
end

#formatObject

Returns the value of attribute format.



14
15
16
# File 'lib/zebra/zpl/datamatrix.rb', line 14

def format
  @format
end

#rowsObject

Returns the value of attribute rows.



14
15
16
# File 'lib/zebra/zpl/datamatrix.rb', line 14

def rows
  @rows
end

#symbol_heightObject

Returns the value of attribute symbol_height.



14
15
16
# File 'lib/zebra/zpl/datamatrix.rb', line 14

def symbol_height
  @symbol_height
end

#widthObject

Returns the value of attribute width.



14
15
16
# File 'lib/zebra/zpl/datamatrix.rb', line 14

def width
  @width
end

Instance Method Details

#orientationObject



26
27
28
# File 'lib/zebra/zpl/datamatrix.rb', line 26

def orientation
  @orientation || 'N'
end

#orientation=(value) ⇒ Object



21
22
23
24
# File 'lib/zebra/zpl/datamatrix.rb', line 21

def orientation=(value)
  raise InvalidOrientationError unless %w[N R I B].include?(value)
  @orientation = value
end

#qualityObject



39
40
41
# File 'lib/zebra/zpl/datamatrix.rb', line 39

def quality
  @quality || 200
end

#quality=(level) ⇒ Object



34
35
36
37
# File 'lib/zebra/zpl/datamatrix.rb', line 34

def quality=(level)
  raise InvalidQualityFactorError unless [0, 50, 80, 100, 140, 200].include?(level.to_i)
  @quality = level
end

#to_zplObject



63
64
65
66
# File 'lib/zebra/zpl/datamatrix.rb', line 63

def to_zpl
  check_attributes
  "^FW#{rotation}^FO#{x},#{y}^BY,,10^BX#{orientation},#{symbol_height},#{quality},#{columns},#{rows},#{format},#{escape_sequence},#{aspect_ratio}^FD#{data}^FS"
end