Class: USPSFlags::Core::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/usps_flags/core/field.rb

Instance Method Summary collapse

Constructor Details

#initialize(style: :regular, color: :white, fly: USPSFlags::Config::BASE_FLY) ⇒ Field

Returns a new instance of Field.



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/usps_flags/core/field.rb', line 10

def initialize(style: :regular, color: :white, fly: USPSFlags::Config::BASE_FLY)
  @style = style
  @fly = fly
  border = color == :white
  @color_code, @past_mid_color, @past_tail_color = send("#{color}_colors")
  @border_svg = if border
    "stroke=\"#000000\" stroke-width=\"#{USPSFlags::Config::BASE_FLY / 600}\" "
  else
    ''
  end

  @hoist = (@fly * 2) / 3
end

Instance Method Details

#svgObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/usps_flags/core/field.rb', line 24

def svg
  case @style
  when :regular
    regular_field
  when :swallowtail
    swallowtail_field
  when :past
    past_field
  end
end