Class: Zebra::Zpl::Barcode

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

Defined Under Namespace

Classes: InvalidNarrowBarWidthError, InvalidRatioError, InvalidWideBarWidthError

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

#heightObject

Returns the value of attribute height.


12
13
14
# File 'lib/zebra/zpl/barcode.rb', line 12

def height
  @height
end

#narrow_bar_widthObject

Returns the value of attribute narrow_bar_width.


13
14
15
# File 'lib/zebra/zpl/barcode.rb', line 13

def narrow_bar_width
  @narrow_bar_width
end

52
53
54
# File 'lib/zebra/zpl/barcode.rb', line 52

def print_human_readable_code
  @print_human_readable_code || false
end

#ratioObject

Returns the value of attribute ratio.


13
14
15
# File 'lib/zebra/zpl/barcode.rb', line 13

def ratio
  @ratio
end

#typeObject

Returns the value of attribute type.


13
14
15
# File 'lib/zebra/zpl/barcode.rb', line 13

def type
  @type
end

#wide_bar_widthObject

Returns the value of attribute wide_bar_width.


13
14
15
# File 'lib/zebra/zpl/barcode.rb', line 13

def wide_bar_width
  @wide_bar_width
end

Instance Method Details

#to_zplObject

[View source]

56
57
58
59
60
# File 'lib/zebra/zpl/barcode.rb', line 56

def to_zpl
  check_attributes
  human_readable = print_human_readable_code ? "Y" : "N"
  "^FW#{rotation}^FO#{x},#{y}^BY#{width},#{ratio},#{height}^B#{type}#{rotation},,#{human_readable}^FD#{data}^FS"
end

#widthObject

[View source]

20
21
22
# File 'lib/zebra/zpl/barcode.rb', line 20

def width
  @width || @narrow_bar_width || @wide_bar_width || 0
end

#width=(value) ⇒ Object

[View source]

16
17
18
# File 'lib/zebra/zpl/barcode.rb', line 16

def width=(value)
  @width = value || 0
end