Sha256: 6304e6cf0ff6cac544845f00537b5eba2d3a0886d3ef96de7a98d205bf00acfe

Contents?: true

Size: 1.21 KB

Versions: 6

Compression:

Stored size: 1.21 KB

Contents

require "zebra/epl/printable"

module Zebra
  module Epl
    class Text
      include Printable

      attr_reader   :font

      def font=(f)
        Font.validate_font f
        @font = f
      end

      def print_mode=(mode)
        PrintMode.validate_mode mode
        @print_mode = mode
      end

      def print_mode
        @print_mode || PrintMode::NORMAL
      end

      def h_multiplier
        @h_multiplier || HorizontalMultiplier::VALUE_1
      end

      def v_multiplier
        @v_multiplier || VerticalMultiplier::VALUE_1
      end

      def print_mode
        @print_mode || PrintMode::NORMAL
      end

      def h_multiplier=(multiplier)
        HorizontalMultiplier.validate_multiplier multiplier
        @h_multiplier = multiplier
      end

      def v_multiplier=(multiplier)
        VerticalMultiplier.validate_multiplier multiplier
        @v_multiplier = multiplier
      end

      def to_epl
        check_attributes
        ["A#{x}", y, rotation, font, h_multiplier, v_multiplier, print_mode, "\"#{data}\""].join(",")
      end

      private

      def check_attributes
        super
        raise MissingAttributeError.new("the font to be used is not given") unless @font
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
zebra-epl-0.0.8 lib/zebra/epl/text.rb
zebra-epl-0.0.7 lib/zebra/epl/text.rb
zebra-epl-0.0.6 lib/zebra/epl/text.rb
zebra-epl-0.0.5 lib/zebra/epl/text.rb
zebra-epl-0.0.2 lib/zebra/epl/text.rb
zebra-epl-0.0.1 lib/zebra/epl/text.rb