Sha256: 792e61e64f40062639d842ed8074faecdc1367eedd1ea3e88dc4d5f7cdb03728

Contents?: true

Size: 879 Bytes

Versions: 3

Compression:

Stored size: 879 Bytes

Contents

module Squib
  module Sprues
    class CropLineDash
      VALIDATION_REGEX = /%r{
        ^(\d*[.])?\d+(in|cm|mm)
        \s+
        (\d*[.])?\d+(in|cm|mm)$
      }x/

      attr_reader :pattern

      def initialize(value, dpi)
        if value == :solid
          @pattern = nil
        elsif value == :dotted
          @pattern = [
            Args::UnitConversion.parse('0.2mm', dpi),
            Args::UnitConversion.parse('0.5mm', dpi)
          ]
        elsif value == :dashed
          @pattern = [
            Args::UnitConversion.parse('2mm', dpi),
            Args::UnitConversion.parse('2mm', dpi)
          ]
        elsif value.is_a? String
          @pattern = value.split(' ').map do |val|
            Args::UnitConversion.parse val, dpi
          end
        else
          raise ArgumentError, 'Unsupported dash style'
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
squib-0.15.2 lib/squib/sprues/crop_line_dash.rb
squib-0.15.1 lib/squib/sprues/crop_line_dash.rb
squib-0.14.2 lib/squib/sprues/crop_line_dash.rb