Class: UspsApi::ProcessingCategory12

Inherits:
Object
  • Object
show all
Defined in:
lib/usps_api/models/processing_category12.rb

Overview

processingCategory12.

Constant Summary collapse

PROCESSING_CATEGORY12 =
[
  # TODO: Write general description for FLATS
  FLATS = 'FLATS'.freeze,

  # TODO: Write general description for MACHINABLE
  MACHINABLE = 'MACHINABLE'.freeze,

  # TODO: Write general description for IRREGULAR
  IRREGULAR = 'IRREGULAR'.freeze,

  # TODO: Write general description for NON_MACHINABLE
  NON_MACHINABLE = 'NON_MACHINABLE'.freeze,

  # TODO: Write general description for NONSTANDARD
  NONSTANDARD = 'NONSTANDARD'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = FLATS) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/usps_api/models/processing_category12.rb', line 32

def self.from_value(value, default_value = FLATS)
  return default_value if value.nil?

  str = value.to_s.strip

  case str.downcase
  when 'flats' then FLATS
  when 'machinable' then MACHINABLE
  when 'irregular' then IRREGULAR
  when 'non_machinable' then NON_MACHINABLE
  when 'nonstandard' then NONSTANDARD
  else
    default_value
  end
end

.validate(value) ⇒ Object



26
27
28
29
30
# File 'lib/usps_api/models/processing_category12.rb', line 26

def self.validate(value)
  return false if value.nil?

  PROCESSING_CATEGORY12.include?(value)
end