Module: EorzeaWeather
- Defined in:
- lib/eorzea_weather/calculator.rb,
lib/eorzea_weather.rb,
lib/eorzea_weather/zone.rb,
lib/eorzea_weather/locale.rb,
lib/eorzea_weather/version.rb,
lib/eorzea_weather/localizer.rb,
lib/eorzea_weather/data/zones.rb,
lib/eorzea_weather/data/locales.rb,
lib/eorzea_weather/data/weathers.rb
Overview
Defined Under Namespace
Modules: Data
Classes: Calculator, Locale, Localizer, Zone
Constant Summary
collapse
- VERSION =
"0.1.1"
Class Method Summary
collapse
-
.find(weather, zone, time: Time.now, max_attempts: 60, count: 1) ⇒ Object
-
.find_next(weather, zone, time: Time.now, max_attempts: 60) ⇒ Object
-
.forecast(zone, time = Time.now) ⇒ Object
-
.forecasts(zone, time: Time.now, count: 6) ⇒ Object
-
.history(zone, time: Time.now, count: 6) ⇒ Object
-
.weather(o) ⇒ Object
-
.zone(o) ⇒ Object
-
.zones ⇒ Object
Class Method Details
.find(weather, zone, time: Time.now, max_attempts: 60, count: 1) ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/eorzea_weather.rb', line 44
def self.find(weather, zone, time: Time.now, max_attempts: 60, count: 1)
weather = self.weather(weather)
result = []
forecast = self.forecast(zone, time)
max_attempts.times do
if forecast.weather == weather
result << forecast
end
forecast = forecast.succ
end
result
end
|
.find_next(weather, zone, time: Time.now, max_attempts: 60) ⇒ Object
40
41
42
|
# File 'lib/eorzea_weather.rb', line 40
def self.find_next(weather, zone, time: Time.now, max_attempts: 60)
find(weather, zone, time: time, max_attempts: max_attempts, count: 1)[0]
end
|
.forecast(zone, time = Time.now) ⇒ Object
59
60
61
|
# File 'lib/eorzea_weather.rb', line 59
def self.forecast(zone, time = Time.now)
Calculator.new(self.zone(zone), time)
end
|
.forecasts(zone, time: Time.now, count: 6) ⇒ Object
63
64
65
66
67
68
69
|
# File 'lib/eorzea_weather.rb', line 63
def self.forecasts(zone, time: Time.now, count: 6)
[forecast(zone, time)].tap do |result|
[0, count - 1].max.times do
result << result.last.succ
end
end
end
|
.history(zone, time: Time.now, count: 6) ⇒ Object
71
72
73
74
75
76
77
|
# File 'lib/eorzea_weather.rb', line 71
def self.history(zone, time: Time.now, count: 6)
[forecast(zone, time)].tap do |result|
[0, count - 1].max.times do
result << result.last.prev
end
end.reverse
end
|
.weather(o) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/eorzea_weather.rb', line 27
def self.weather(o)
if o.kind_of?(String)
o = Data::Locales::WEATHER_MAP[o] || o
o = o.to_sym
end
if Data::Weathers::LIST.include?(o)
return o
else
raise KeyError, "#{o} is not valid weather"
end
end
|
.zones ⇒ Object
11
12
13
|
# File 'lib/eorzea_weather.rb', line 11
def self.zones
Data::Zones::MAP
end
|