Class: FFXI::VanaMoonCountdown
- Inherits:
-
Util::RubyBean
- Object
- Util::RubyBean
- FFXI::VanaMoonCountdown
- Defined in:
- lib/Vana/moon_countdown.rb
Constant Summary
Constants included from Constants
Constants::BASIS_DATE, Constants::DAY, Constants::HOUR, Constants::MINUTE, Constants::MOON_DATE, Constants::MS_BASIS_DATE, Constants::MS_BASIS_VANA, Constants::MS_DAY, Constants::MS_GAME_DAY, Constants::MS_HOUR, Constants::MS_MINUTE, Constants::MS_MONTH, Constants::MS_MOON_DATE, Constants::MS_SECOND, Constants::MS_YEAR
Instance Attribute Summary collapse
-
#earth_time ⇒ Object
readonly
Returns the value of attribute earth_time.
-
#elapsed_time ⇒ Object
readonly
Returns the value of attribute elapsed_time.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ VanaMoonCountdown
constructor
A new instance of VanaMoonCountdown.
- #update_earth_time(earth_time) ⇒ Object
- #update_moon(moon) ⇒ Object
- #update_vana_time(vt) ⇒ Object
Methods included from Common
Methods inherited from Util::RubyBean
#add_listener, #has_listeners?, property, #remove_listener
Constructor Details
#initialize(opts = {}) ⇒ VanaMoonCountdown
Returns a new instance of VanaMoonCountdown.
12 13 14 15 16 |
# File 'lib/Vana/moon_countdown.rb', line 12 def initialize(opts={}) super() add_listener(opts[:listener]) if opts[:listener] update_moon(opts[:moon]) if opts[:moon] end |
Instance Attribute Details
#earth_time ⇒ Object (readonly)
Returns the value of attribute earth_time.
46 47 48 |
# File 'lib/Vana/moon_countdown.rb', line 46 def earth_time @earth_time end |
#elapsed_time ⇒ Object (readonly)
Returns the value of attribute elapsed_time.
46 47 48 |
# File 'lib/Vana/moon_countdown.rb', line 46 def elapsed_time @elapsed_time end |
Instance Method Details
#update_earth_time(earth_time) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/Vana/moon_countdown.rb', line 28 def update_earth_time(earth_time) raise "Input needs to be a Time object" if ! earth_time.is_a? Time @earth_time = earth_time localtime = (@earth_time.to_f * 1000).to_i @elapsed_time = (localtime - MS_MOON_DATE.to_i) % MS_GAME_DAY update_countdowns if @moon_days end |
#update_moon(moon) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/Vana/moon_countdown.rb', line 18 def update_moon(moon) raise "Input needs to be a VanaMoon object" if ! moon.is_a? VanaMoon @next_phase_target = moon.next_phase_target @optimal_phase_target = moon.optimal_phase_target @moon_days = moon.moon_days update_earth_time moon.earth_time end |
#update_vana_time(vt) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/Vana/moon_countdown.rb', line 38 def update_vana_time(vt) if vt.is_a? VanaTime update_earth_time(vt.earth_time) else update_earth_time(FFXI::Common.vana_to_earth(vt)) end end |