Sha256: 663e9900d3f0185b80eabf68d56c1b4ad63f162bed12aa41643435363cd0d926

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

require "zebra/epl/printable"

module Zebra
  module Epl
    class Box
      include Printable

      class InvalidLineThickness < StandardError; end

      attr_reader :line_thickness, :end_position, :end_x, :end_y

      def line_thickness=(thickness)
        raise InvalidLineThickness unless thickness.nil? || thickness.to_i.to_s == thickness.to_s
        @line_thickness = thickness
      end

      def end_position=(coords)
        @end_position, @end_x, @end_y = coords, coords[0], coords[1]
      end

      def to_epl
        check_attributes
        ["X#{x}", y, line_thickness, end_x, end_y].join(",")
      end

      private

      def has_data?
        false
      end

      def check_attributes
        super
        raise MissingAttributeError.new("the line thickness is not given") unless line_thickness
        raise MissingAttributeError.new("the horizontal end position (X) is not given") unless end_x
        raise MissingAttributeError.new("the vertical end position (Y) is not given") unless end_y
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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