class Zebra::Zpl::Text

Attributes

bold[R]
font_size[R]
font_type[R]
hanging_indent[R]
line_spacing[R]
width[R]

Public Instance Methods

bold=(value) click to toggle source
# File lib/zebra/zpl/text.rb, line 17
def bold=(value)
  @bold = value
end
font_size=(f) click to toggle source
# File lib/zebra/zpl/text.rb, line 12
def font_size=(f)
  FontSize.validate_font_size f
  @font_size = f
end
font_type=(type) click to toggle source
# File lib/zebra/zpl/text.rb, line 42
def font_type=(type)
  FontType.validate_font_type type
  @font_type = type
end
hanging_indent=(value) click to toggle source
# File lib/zebra/zpl/text.rb, line 38
def hanging_indent=(value)
  @hanging_indent = value || 0
end
line_spacing=(value) click to toggle source
# File lib/zebra/zpl/text.rb, line 34
def line_spacing=(value)
  @line_spacing = value || 0
end
max_lines() click to toggle source
# File lib/zebra/zpl/text.rb, line 72
def max_lines
  @max_lines || 4
end
max_lines=(value) click to toggle source
# File lib/zebra/zpl/text.rb, line 29
def max_lines=(value)
  raise InvalidMaxLinesError unless value.to_i >= 1
  @max_lines = value
end
print_mode() click to toggle source
print_mode=(mode) click to toggle source
to_zpl() click to toggle source

def h_multiplier=(multiplier)

HorizontalMultiplier.validate_multiplier multiplier
@h_multiplier = multiplier

end

def v_multiplier=(multiplier)

VerticalMultiplier.validate_multiplier multiplier
@v_multiplier = multiplier

end

# File lib/zebra/zpl/text.rb, line 86
def to_zpl
  check_attributes
  if !bold.nil?
    "^FW#{rotation}^CF#{font_type},#{font_size}^CI28^FO#{x+2},#{y}^FB#{width},#{max_lines},#{line_spacing},#{justification},#{hanging_indent}^FD#{data}^FS" +
    "^FW#{rotation}^CF#{font_type},#{font_size}^CI28^FO#{x},#{y+2}^FB#{width},#{max_lines},#{line_spacing},#{justification},#{hanging_indent}^FD#{data}^FS"
  else
    "^FW#{rotation}^CF#{font_type},#{font_size}^CI28^FO#{x},#{y}^FB#{width},#{max_lines},#{line_spacing},#{justification},#{hanging_indent}^FD#{data}^FS"
  end
end
width=(width) click to toggle source
# File lib/zebra/zpl/text.rb, line 21
def width=(width)
  unless (margin.nil? || margin < 1)
    @width = (width - (margin*2))
  else
    @width = width || 0
  end
end

Private Instance Methods

check_attributes() click to toggle source
Calls superclass method Zebra::Zpl::Printable#check_attributes
# File lib/zebra/zpl/text.rb, line 98
def check_attributes
  super
  raise MissingAttributeError.new("the font_size to be used is not given") unless @font_size
end