Class: Squib::Sprues::CropLineDash

Inherits:
Object
  • Object
show all
Defined in:
lib/squib/sprues/crop_line_dash.rb

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, dpi) ⇒ CropLineDash

Returns a new instance of CropLineDash


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/squib/sprues/crop_line_dash.rb', line 12

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

Instance Attribute Details

#patternObject (readonly)


10
11
12
# File 'lib/squib/sprues/crop_line_dash.rb', line 10

def pattern
  @pattern
end