Class: WalmartApIs::Unit2
- Inherits:
-
Object
- Object
- WalmartApIs::Unit2
- Defined in:
- lib/walmart_ap_is/models/unit2.rb
Overview
Unit2.
Constant Summary collapse
- UNIT2 =
[ # TODO: Write general description for EA EA = 'EA'.freeze, # TODO: Write general description for EACH EACH = 'EACH'.freeze, # TODO: Write general description for CASE CASE = 'CASE'.freeze, # TODO: Write general description for CARTON CARTON = 'CARTON'.freeze ].freeze
Class Method Summary collapse
Class Method Details
.from_value(value, default_value = EA) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/walmart_ap_is/models/unit2.rb', line 29 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 when 'case' then CASE when 'carton' then CARTON else default_value end end |
.validate(value) ⇒ Object
23 24 25 26 27 |
# File 'lib/walmart_ap_is/models/unit2.rb', line 23 def self.validate(value) return false if value.nil? UNIT2.include?(value) end |