class Zebra::Zpl::Barcode

Attributes

height[RW]
narrow_bar_width[R]
print_human_readable_code[W]
ratio[R]
type[R]
wide_bar_width[R]

Public Instance Methods

narrow_bar_width=(value) click to toggle source
# File lib/zebra/zpl/barcode.rb, line 42
def narrow_bar_width=(value)
  raise InvalidNarrowBarWidthError unless (1..10).include?(value.to_i)
  @narrow_bar_width = value
end
print_human_readable_code() click to toggle source
ratio=(value) click to toggle source
# File lib/zebra/zpl/barcode.rb, line 29
def ratio=(value)
  raise InvalidRatioError unless value.to_f >= 2.0 && value.to_f <= 3.0
  @ratio = value
end
to_zpl() click to toggle source
# 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
type=(type) click to toggle source
# File lib/zebra/zpl/barcode.rb, line 24
def type=(type)
  BarcodeType.validate_barcode_type(type)
  @type = type
end
wide_bar_width=(value) click to toggle source
# File lib/zebra/zpl/barcode.rb, line 47
def wide_bar_width=(value)
  raise InvalidWideBarWidthError unless (2..30).include?(value.to_i)
  @wide_bar_width = value
end
width() click to toggle source
# File lib/zebra/zpl/barcode.rb, line 20
def width
  @width || @narrow_bar_width || @wide_bar_width || 0
end
width=(value) click to toggle source
# File lib/zebra/zpl/barcode.rb, line 16
def width=(value)
  @width = value || 0
end

Private Instance Methods

check_attributes() click to toggle source
Calls superclass method Zebra::Zpl::Printable#check_attributes
# File lib/zebra/zpl/barcode.rb, line 64
def check_attributes
  super
  raise MissingAttributeError.new("the barcode type to be used is not given") unless @type
  raise MissingAttributeError.new("the height to be used is not given") unless @height
  raise MissingAttributeError.new("the width to be used is not given") unless @width || @narrow_bar_width || @wide_bar_width
end