Sha256: b92051212e308c4c11b51ab4b363cc636739b5a630195168453b7694a488e871
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
require "will_it_rain/version" require_relative "../config/initialize" require_relative "./will_it_rain/data_point" module WillItRain module Default THRESHOLD = 10 SUMMARY = "No chance of precipitation today." end module_function def at_location?(latitude, longtitude, threshold=Default::THRESHOLD) with_chances(latitude, longtitude, threshold)[:it_will_rain] end def with_chances(latitude, longtitude, threshold=Default::THRESHOLD) dp = daily_data_points(latitude, longtitude).max_by(&:percentage) {it_will_rain: dp.surpasses_threshold?(threshold), chances: "#{dp.percentage}%"} end def get_summaries(latitude, longtitude, threshold=Default::THRESHOLD) data_points = daily_data_points(latitude, longtitude) if data_points.any? { |dp| dp.surpasses_threshold?(threshold) } data_points.map(&:summary).uniq else [Default::SUMMARY] end end private module_function def daily_data_points(latitude, longtitude) forecast = ForecastIO.forecast(latitude, longtitude) forecast.daily.data.map { |dp| DataPoint.new(dp) } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
will_it_rain-0.1.0 | lib/will_it_rain.rb |