Class: WalmartApIs::ConditionType

Inherits:
Object
  • Object
show all
Defined in:
lib/walmart_ap_is/models/condition_type.rb

Overview

ConditionType.

Constant Summary collapse

CONDITION_TYPE =
[
  # TODO: Write general description for NEW_NEW
  NEW_NEW = 'new_new'.freeze,

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

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

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

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

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

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

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

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = NEW_NEW) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/walmart_ap_is/models/condition_type.rb', line 44

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

  str = value.to_s.strip

  case str.downcase
  when 'new_new' then NEW_NEW
  when 'used_like_new' then USED_LIKE_NEW
  when 'used_very_good' then USED_VERY_GOOD
  when 'used_good' then USED_GOOD
  when 'used_acceptable' then USED_ACCEPTABLE
  when 'collectible_like_new' then COLLECTIBLE_LIKE_NEW
  when 'collectible_very_good' then COLLECTIBLE_VERY_GOOD
  when 'collectible_good' then COLLECTIBLE_GOOD
  when 'collectible_acceptable' then COLLECTIBLE_ACCEPTABLE
  else
    default_value
  end
end

.validate(value) ⇒ Object



38
39
40
41
42
# File 'lib/walmart_ap_is/models/condition_type.rb', line 38

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

  CONDITION_TYPE.include?(value)
end