Class: WalmartApIs::WeightUnit
- Inherits:
-
Object
- Object
- WalmartApIs::WeightUnit
- Defined in:
- lib/walmart_ap_is/models/weight_unit.rb
Overview
WeightUnit.
Constant Summary collapse
- WEIGHT_UNIT =
[ # TODO: Write general description for LB LB = 'LB'.freeze, # TODO: Write general description for KG KG = 'KG'.freeze, # TODO: Write general description for OZ OZ = 'OZ'.freeze ].freeze
Class Method Summary collapse
Class Method Details
.from_value(value, default_value = LB) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/walmart_ap_is/models/weight_unit.rb', line 26 def self.from_value(value, default_value = LB) return default_value if value.nil? str = value.to_s.strip case str.downcase when 'lb' then LB when 'kg' then KG when 'oz' then OZ else default_value end end |
.validate(value) ⇒ Object
20 21 22 23 24 |
# File 'lib/walmart_ap_is/models/weight_unit.rb', line 20 def self.validate(value) return false if value.nil? WEIGHT_UNIT.include?(value) end |