Sha256: 38c899da0d9a464ee4ee4ef2d0c225e6e9ed83a8a23f814ec073cf0fc7831e65

Contents?: true

Size: 914 Bytes

Versions: 6

Compression:

Stored size: 914 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

6 entries across 6 versions & 1 rubygems

Version Path
squib-0.15.3 lib/squib/sprues/crop_line_dash.rb
squib-0.15.0 lib/squib/sprues/crop_line_dash.rb
squib-0.14.3.pre1 lib/squib/sprues/crop_line_dash.rb
squib-0.14.1 lib/squib/sprues/crop_line_dash.rb
squib-0.14.0 lib/squib/sprues/crop_line_dash.rb
squib-0.14.beta1 lib/squib/sprues/crop_line_dash.rb