Class: UspsApi::SortBy

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

Overview

sortBy.

Constant Summary collapse

SORT_BY =
[
  # TODO: Write general description for IMAGENAME
  IMAGENAME = 'imageName'.freeze,

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = IMAGENAME) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/usps_api/models/sort_by.rb', line 23

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

  str = value.to_s.strip

  case str.downcase
  when 'imagename' then IMAGENAME
  when 'createddatetime' then CREATEDDATETIME
  else
    default_value
  end
end

.validate(value) ⇒ Object



17
18
19
20
21
# File 'lib/usps_api/models/sort_by.rb', line 17

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

  SORT_BY.include?(value)
end