Class: USPSFlags::Core::Icons::Trident

Inherits:
Object
  • Object
show all
Includes:
USPSFlags::Core::Icons::TridentParts::Hashes
Defined in:
lib/usps_flags/core/icons/trident.rb

Instance Method Summary collapse

Methods included from USPSFlags::Core::Icons::TridentParts::Hashes

#circle_hash, #delta_hash, #delta_mask_points, #delta_points, #standard_hash

Constructor Details

#initialize(type, color: :blue, field_color: nil) ⇒ Trident

Returns a new instance of Trident.



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/usps_flags/core/icons/trident.rb', line 14

def initialize(type, color: :blue, field_color: nil)
  valid_types = %i[s d stf n]
  raise "Error: Invalid trident type: #{type}. Options are #{valid_types}." unless valid_types.include?(type)

  @type = type

  @trident_config = USPSFlags.configuration.trident
  load_measures
  load_measures_from_top
  load_main_length
  configure_trident_segments
  configure_colors(color, field_color)
end

Instance Method Details

#svgObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/usps_flags/core/icons/trident.rb', line 28

def svg
  svg = +''
  svg << '<g mask="url(#delta-mask)">' if @type == :d
  svg << '<g mask="url(#circle-mask-for-main-spike)">' if @type == :stf
  @trident_segments.each { |seg| svg << add_trident_segment(seg) }
  svg << '</g>' if %i[d stf].include?(@type)
  svg << add_hash

  svg
end