class Zebra::Zpl::Graphic

Constants

BOX
CIRCLE
DIAGONAL
ELLIPSE
SYMBOL

Attributes

color[R]
graphic_height[R]
graphic_type[R]
graphic_width[R]
line_thickness[R]
orientation[R]
rounding_degree[R]
symbol_type[R]

Public Instance Methods

color=(value) click to toggle source
# File lib/zebra/zpl/graphic.rb, line 41
def color=(value)
  raise InvalidColorError unless %w[B W].include?(value&.upcase)
  @color = value
end
graphic_height=(height) click to toggle source
# File lib/zebra/zpl/graphic.rb, line 32
def graphic_height=(height)
  @graphic_height = height
end
graphic_type=(type) click to toggle source
# File lib/zebra/zpl/graphic.rb, line 23
def graphic_type=(type)
  raise InvalidGraphicType unless %w(E B D C S).include? type
  @graphic_type = type
end
graphic_width=(width) click to toggle source
# File lib/zebra/zpl/graphic.rb, line 28
def graphic_width=(width)
  @graphic_width = width
end
line_thickness=(thickness) click to toggle source
# File lib/zebra/zpl/graphic.rb, line 36
def line_thickness=(thickness)
  raise InvalidLineThickness unless thickness.nil? || thickness.to_i.to_s == thickness.to_s
  @line_thickness = thickness
end
orientation=(value) click to toggle source
# File lib/zebra/zpl/graphic.rb, line 46
def orientation=(value)
  raise InvalidOrientationError unless %w[R L].include?(value&.upcase)
  @orientation = value
end
rounding_degree=(value) click to toggle source
# File lib/zebra/zpl/graphic.rb, line 51
def rounding_degree=(value)
  raise InvalidRoundingDegree unless (0..8).include?(value.to_i)
  @rounding_degree = value
end
symbol_type=(value) click to toggle source
# File lib/zebra/zpl/graphic.rb, line 56
def symbol_type=(value)
  raise InvalidSymbolType unless %w[A B C D E].include?(value.upcase)
  @symbol_type = value
end
to_zpl() click to toggle source
# File lib/zebra/zpl/graphic.rb, line 61
def to_zpl
  check_attributes
  graphic = case graphic_type
  when "B"
    "B#{graphic_width},#{graphic_height},#{line_thickness},#{color},#{rounding_degree}"
  when "C"
    "C#{graphic_width},#{line_thickness},#{color}"
  when "D"
    "D#{graphic_width},#{graphic_height},#{line_thickness},#{color},#{orientation}"
  when "E"
    "E#{graphic_width},#{graphic_height},#{line_thickness},#{color}"
  when "S"
    sym = !symbol_type.nil? ? "^FD#{symbol_type}" : ''
    "S,#{graphic_height},#{graphic_width}#{sym}"
  end
  "^FW#{rotation}^FO#{x},#{y}^G#{graphic}^FS"
end

Private Instance Methods

check_attributes() click to toggle source
Calls superclass method Zebra::Zpl::Printable#check_attributes
# File lib/zebra/zpl/graphic.rb, line 85
def check_attributes
  super
  raise InvalidGraphicType if @graphic_type.nil?
end
has_data?() click to toggle source
# File lib/zebra/zpl/graphic.rb, line 81
def has_data?
  false
end