Class: WalmartApIs::UnitOfWeight
- Inherits:
-
Object
- Object
- WalmartApIs::UnitOfWeight
- Defined in:
- lib/walmart_ap_is/models/unit_of_weight.rb
Overview
Unit of the weight being measured.
Constant Summary collapse
- UNIT_OF_WEIGHT =
[ # TODO: Write general description for LB LB = 'LB'.freeze, # TODO: Write general description for KG KG = 'KG'.freeze ].freeze
Class Method Summary collapse
Class Method Details
.from_value(value, default_value = LB) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/walmart_ap_is/models/unit_of_weight.rb', line 23 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 else default_value end end |
.validate(value) ⇒ Object
17 18 19 20 21 |
# File 'lib/walmart_ap_is/models/unit_of_weight.rb', line 17 def self.validate(value) return false if value.nil? UNIT_OF_WEIGHT.include?(value) end |