Module: WeatherData::Humidity
- Defined in:
- lib/weather_data/humidity.rb,
lib/weather_data/humidity/relative.rb
Defined Under Namespace
Classes: Relative
Class Method Summary collapse
Class Method Details
.parse(s) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/weather_data/humidity.rb', line 7 def self.parse(s) _, points, units = /\b(\d+(?:\.\d+)?)%/.match(s).to_a raise ArgumentError.new(%Q{"#{s.inspect}" doesn't contain humidity}) unless points percents = points.to_f raise ArgumentError.new("Invalid value for relative humidity: #{percents.inspect}") unless percents > 0 && percents <= 100 Relative.new(percents) end |