Class: WalmartApIs::Unit
- Inherits:
-
Object
- Object
- WalmartApIs::Unit
- Defined in:
- lib/walmart_ap_is/models/unit.rb
Overview
Unit.
Constant Summary collapse
- UNIT =
[ # TODO: Write general description for EA EA = 'EA'.freeze, # TODO: Write general description for EACH EACH = 'EACH'.freeze ].freeze
Class Method Summary collapse
Class Method Details
.from_value(value, default_value = EA) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/walmart_ap_is/models/unit.rb', line 23 def self.from_value(value, default_value = EA) return default_value if value.nil? str = value.to_s.strip case str.downcase when 'ea' then EA when 'each' then EACH else default_value end end |
.validate(value) ⇒ Object
17 18 19 20 21 |
# File 'lib/walmart_ap_is/models/unit.rb', line 17 def self.validate(value) return false if value.nil? UNIT.include?(value) end |