Class: Zebra::Zpl::Graphic

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

Defined Under Namespace

Classes: InvalidColorError, InvalidGraphicType, InvalidLineThickness, InvalidOrientationError, InvalidRoundingDegree, InvalidSymbolType

Constant Summary collapse

BOX =
"B"
CIRCLE =
"C"
DIAGONAL =
"D"
ELLIPSE =
"E"
SYMBOL =
"S"

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

#colorObject

Returns the value of attribute color.



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

def color
  @color
end

#graphic_heightObject

Returns the value of attribute graphic_height.



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

def graphic_height
  @graphic_height
end

#graphic_typeObject

Returns the value of attribute graphic_type.



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

def graphic_type
  @graphic_type
end

#graphic_widthObject

Returns the value of attribute graphic_width.



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

def graphic_width
  @graphic_width
end

#line_thicknessObject

Returns the value of attribute line_thickness.



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

def line_thickness
  @line_thickness
end

#orientationObject

Returns the value of attribute orientation.



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

def orientation
  @orientation
end

#rounding_degreeObject

Returns the value of attribute rounding_degree.



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

def rounding_degree
  @rounding_degree
end

#symbol_typeObject

Returns the value of attribute symbol_type.



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

def symbol_type
  @symbol_type
end

Instance Method Details

#to_zplObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/zebra/zpl/graphic.rb', line 61

def to_zpl
  check_attributes
  graphic = case graphic_type
  when BOX
    "^GB#{graphic_width},#{graphic_height},#{line_thickness},#{color},#{rounding_degree}"
  when CIRCLE
    "^GC#{graphic_width},#{line_thickness},#{color}"
  when DIAGONAL
    "^GD#{graphic_width},#{graphic_height},#{line_thickness},#{color},#{orientation}"
  when ELLIPSE
    "^GE#{graphic_width},#{graphic_height},#{line_thickness},#{color}"
  when SYMBOL
    sym = !symbol_type.nil? ? "^FD#{symbol_type}" : ''
    "^GS,#{graphic_height},#{graphic_width}#{sym}"
  else
    raise InvalidGraphicType
  end
  "^FW#{rotation}^FO#{x},#{y}#{graphic}^FS"
end