Class: USPSFlags::Helpers

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

Overview

Container class for helper methods.

Since:

  • 0.1.5

Class Method Summary collapse

Class Method Details

.valid_flags(type = :all) ⇒ Array

Valid options for flag generation.

Parameters:

  • type (Symbol) (defaults to: :all)

    Specify subset of flags.

Options Hash (type):

  • :all (Symbol)

    All flags

  • :officer (Symbol)

    Officer flags

  • :insignia (Symbol)

    Insignia-eligible officer flags (no past officers)

  • :squadron (Symbol)

    Squadron-level officer flags

  • :district (Symbol)

    District-level officer flags

  • :national (Symbol)

    National-level officer flags

  • :special (Symbol)

    Special flags

  • :us (Symbol)

    US flag

Returns:

  • (Array)

    Valid options for flag generation (based on the provided type).

Since:

  • 0.1.5



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/usps_flags/helpers.rb', line 16

def valid_flags(type = :all)
  squadron_past = %w[PLTC PC]
  squadron_elected = %w[1LT LTC CDR]
  squadron_swallowtail = %w[PORTCAP FLEETCAP LT FLT]
  district_past = %w[PDLTC PDC]
  district_elected = %w[D1LT DLTC DC]
  district_swallowtail = %w[DLT DAIDE DFLT]
  national_past = %w[PSTFC PRC PVC PCC]
  national_elected = %w[NAIDE NFLT STFC RC VC CC]
  special = %w[CRUISE OIC ENSIGN WHEEL]
  us = %w[US]

  squadron = squadron_past + squadron_elected + squadron_swallowtail
  district = district_past + district_elected + district_swallowtail
  national = national_past + national_elected
  past = squadron_past + district_past + national_past

  case type
  when :all
    squadron + district + national + special + us
  when :officer
    squadron + district + national
  when :insignia
    squadron + district + national - past
  when :squadron
    squadron
  when :district
    district
  when :national
    national
  when :special
    special
  when :us
    us
  when :past
    past
  when :swallowtail
    past + squadron_swallowtail + district_swallowtail
  when :bridge
    squadron_elected.last(2) + squadron_past.last(2) + 
    district_elected.last(2) + district_past.last(2) + 
    national_elected.last(2) + national_past.last(2)
  when :command
    [squadron_elected.last, squadron_past.last,
    district_elected.last, district_past.last,
    national_elected.last, national_past.last]
  end
end