Class: Zebra::Zpl::Text

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

Defined Under Namespace

Classes: InvalidMaxLinesError

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

#boldObject

Returns the value of attribute bold.



10
11
12
# File 'lib/zebra/zpl/text.rb', line 10

def bold
  @bold
end

#font_sizeObject

Returns the value of attribute font_size.



10
11
12
# File 'lib/zebra/zpl/text.rb', line 10

def font_size
  @font_size
end

#font_typeObject

Returns the value of attribute font_type.



10
11
12
# File 'lib/zebra/zpl/text.rb', line 10

def font_type
  @font_type
end

#hanging_indentObject

Returns the value of attribute hanging_indent.



10
11
12
# File 'lib/zebra/zpl/text.rb', line 10

def hanging_indent
  @hanging_indent
end

#line_spacingObject

Returns the value of attribute line_spacing.



10
11
12
# File 'lib/zebra/zpl/text.rb', line 10

def line_spacing
  @line_spacing
end

#reverse_printObject



56
57
58
# File 'lib/zebra/zpl/text.rb', line 56

def reverse_print
  @reverse_print || false
end

#widthObject

Returns the value of attribute width.



10
11
12
# File 'lib/zebra/zpl/text.rb', line 10

def width
  @width
end

Instance Method Details

#max_linesObject



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

def max_lines
  @max_lines || 4
end

#max_lines=(value) ⇒ Object



30
31
32
33
# File 'lib/zebra/zpl/text.rb', line 30

def max_lines=(value)
  raise InvalidMaxLinesError unless value.to_i >= 1
  @max_lines = value
end

#to_zplObject



60
61
62
63
64
65
66
67
68
# File 'lib/zebra/zpl/text.rb', line 60

def to_zpl
  check_attributes
  if !bold.nil?
    "^FW#{rotation}^A#{font_type},#{font_size}^CI28^FO#{x+1},#{y}^FB#{width},#{max_lines},#{line_spacing},#{justification},#{hanging_indent}#{appear_in_reverse}^FD#{data}^FS" +
    "^FW#{rotation}^A#{font_type},#{font_size}^CI28^FO#{x},#{y+1}^FB#{width},#{max_lines},#{line_spacing},#{justification},#{hanging_indent}#{appear_in_reverse}^FD#{data}^FS"
  else
    "^FW#{rotation}^A#{font_type},#{font_size}^CI28^FO#{x},#{y}^FB#{width},#{max_lines},#{line_spacing},#{justification},#{hanging_indent}#{appear_in_reverse}^FD#{data}^FS"
  end
end