class EorzeaWeather::Calculator
Attributes
time[R]
zone[R]
Public Class Methods
new(zone, time)
click to toggle source
# File lib/eorzea_weather/calculator.rb, line 6 def initialize(zone, time) @zone = zone @time = time.utc end
Public Instance Methods
days()
click to toggle source
Number of days passed in Eorzea (1 eorzean day is 4200 seconds in local time)
# File lib/eorzea_weather/calculator.rb, line 43 def days @days ||= @time.to_i / 4200 end
end_hour()
click to toggle source
# File lib/eorzea_weather/calculator.rb, line 52 def end_hour # 0..7 => 8, 8..15 => 16, 16..23 => 0 ((hour + 8) - (hour % 8)) % 24 end
end_time()
click to toggle source
# File lib/eorzea_weather/calculator.rb, line 33 def end_time EorzeaTime.new(end_hour * 3600).next_occurrence(time: @time) end
hour()
click to toggle source
Eorzean Hour (1 eorzean hour is 175 seconds in local time)
# File lib/eorzea_weather/calculator.rb, line 38 def hour @hour ||= @time.to_i / 175 % 24 end
inspect()
click to toggle source
# File lib/eorzea_weather/calculator.rb, line 21 def inspect "#<#{self.class.name}: #{zone.id}, #{time} (#{start_hour}-#{end_hour}: #{weather})>" end
prev()
click to toggle source
# File lib/eorzea_weather/calculator.rb, line 11 def prev self.class.new(@zone, start_time - 1) end
rate()
click to toggle source
# File lib/eorzea_weather/calculator.rb, line 57 def rate @rate ||= begin base = (days * 0x64) + end_hour step1 = (base << 0xb & 0xffffffff) ^ base step2 = (step1 >> 8 & 0xffffffff) ^ step1 step2 % 0x64 end end
start_hour()
click to toggle source
# File lib/eorzea_weather/calculator.rb, line 47 def start_hour # 0..7 => 0, 8..15 => 8, 16..23 => 16 hour - (hour % 8) end
start_time()
click to toggle source
# File lib/eorzea_weather/calculator.rb, line 29 def start_time EorzeaTime.new(start_hour * 3600).last_occurrence(time: @time) end
succ()
click to toggle source
# File lib/eorzea_weather/calculator.rb, line 15 def succ self.class.new(@zone, end_time + 1) end
weather()
click to toggle source
# File lib/eorzea_weather/calculator.rb, line 25 def weather @weather ||= @zone.find_rate(rate) end