Class: Verizon::ThresholdUnit
- Inherits:
-
Object
- Object
- Verizon::ThresholdUnit
- Defined in:
- lib/verizon/models/threshold_unit.rb
Overview
The units of the threshold. This can be KB, Kilobits, MB, Megabits, or GB, Gigabits
Constant Summary collapse
- THRESHOLD_UNIT =
[ # TODO: Write general description for KB KB = 'KB'.freeze, # TODO: Write general description for MB MB = 'MB'.freeze, # TODO: Write general description for GB GB = 'GB'.freeze ].freeze
Class Method Summary collapse
Class Method Details
.from_value(value, default_value = KB) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/verizon/models/threshold_unit.rb', line 27 def self.from_value(value, default_value = KB) return default_value if value.nil? str = value.to_s.strip case str.downcase when 'kb' then KB when 'mb' then MB when 'gb' then GB else default_value end end |
.validate(value) ⇒ Object
21 22 23 24 25 |
# File 'lib/verizon/models/threshold_unit.rb', line 21 def self.validate(value) return false if value.nil? THRESHOLD_UNIT.include?(value) end |