Class: USPSFlags::Config

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

Overview

Container class for configuration values.

Since:

  • 0.1.5

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Config

Configuration constructor

Parameters:

  • flag_dir (String)

    The path to the flags directory.

  • clear (Boolean)

    Whether to clear out the specified flags_dir.

Yields:

  • (_self)

Yield Parameters:

Since:

  • 0.1.5



22
23
24
25
# File 'lib/usps_flags/config.rb', line 22

def initialize
  get_defaults
  yield self if block_given?
end

Instance Attribute Details

#clearObject

Since:

  • 0.1.5



16
17
18
# File 'lib/usps_flags/config.rb', line 16

def clear
  @clear
end

#flags_dirObject

Since:

  • 0.1.5



16
17
18
# File 'lib/usps_flags/config.rb', line 16

def flags_dir
  @flags_dir
end

Instance Method Details

#log_pathString

Alias for the directory to store generated log files.

Returns:

  • (String)

    The current path to the logs directory.

Since:

  • 0.1.5



84
85
86
87
88
89
90
# File 'lib/usps_flags/config.rb', line 84

def log_path
  if defined?(::Rails)
    "#{::Rails.root}/log"
  else
    "#{USPSFlags.configuration.flags_dir}/log"
  end
end

#tridentHash

Base configuration values for trident insignia.

All other values are derived from these, or directly from the constant sizes.

Returns:

  • (Hash)

    RThe configuration values for tridents.

Since:

  • 0.1.5



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
64
65
66
67
# File 'lib/usps_flags/config.rb', line 32

def trident
  center_point_height = USPSFlags::Config::BASE_FLY / 48 * 23 / 8
  side_point_height = USPSFlags::Config::BASE_FLY / 48 * 21 / 8
  bar_width = USPSFlags::Config::BASE_FLY / 48 * 5 / 4
  {
    height: trident_heights,

    center_point: BASE_FLY / 2,

    width: USPSFlags::Config::BASE_FLY * 5 / 32,

    bar_width: bar_width,

    center_point_height: center_point_height,
    side_point_height: side_point_height,

    main_point_barb: USPSFlags::Config::BASE_HOIST / 82,

    crossbar_from_top: USPSFlags::Config::BASE_HOIST / 4 + bar_width / 5,

    side_spike_height: USPSFlags::Config::BASE_HOIST / 4 - side_point_height - bar_width * 3 / 5,

    hash_width: USPSFlags::Config::BASE_FLY * 47 / 528,

    delta_height: USPSFlags::Config::BASE_FLY * 33 / 240,
    delta_gap_height: USPSFlags::Config::BASE_FLY / 16,
    delta_gap_width: bar_width * 5 / 4,
    delta_width: USPSFlags::Config::BASE_FLY * 43 / 768,
    delta_from_bottom: USPSFlags::Config::BASE_HOIST * 10 / 64,
    delta_gap_scale: 0.40,
    delta_gap_x: USPSFlags::Config::BASE_HOIST * 144 / 128,
    delta_gap_y: USPSFlags::Config::BASE_HOIST * 221 / 256,

    circle_height_adj: USPSFlags::Config::BASE_FLY / 800
  }
end

#trident_heightsHash

Height values for trident insignia.

Returns:

  • (Hash)

    The height values for tridents.

Since:

  • 0.1.5



72
73
74
75
76
77
78
79
# File 'lib/usps_flags/config.rb', line 72

def trident_heights
  {
    s:   USPSFlags::Config::BASE_HOIST / 2,
    d:   USPSFlags::Config::BASE_HOIST * 5 / 8,
    stf: USPSFlags::Config::BASE_HOIST * 3 / 4,
    n:   USPSFlags::Config::BASE_HOIST * 3 / 4
  }
end