Class: FFXI::VanaMoon

Inherits:
Util::RubyBean show all
Includes:
Common, Constants
Defined in:
lib/Vana/moon.rb

Constant Summary collapse

MOON_PHASES =
["Full", "Waning Gibbous", "Last Quarter Moon",
"Waning Crescent", "New Moon", "Waxing Crescent", "First Quarter Moon",
"Waxing Gibbous"]
SHORT_MOON_PHASES =
["FM", "WNG", "LQM", "WNC", "NM", "WXC", "FQM", "WXG"]

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Common

earth_to_vana, vana_to_earth

Methods inherited from Util::RubyBean

#add_listener, #has_listeners?, property, #remove_listener

Constructor Details

#initialize(opts = {}) ⇒ VanaMoon

Returns a new instance of VanaMoon.



25
26
27
28
29
30
31
32
33
34
# File 'lib/Vana/moon.rb', line 25

def initialize(opts={})
 super()
 add_listener(opts[:listener]) if opts[:listener]

 if opts[:vana_time].is_a? VanaTime
  update_earth_time opts[:vana_time].earth_time
 elsif opts[:earth_time]
  update_earth_time opts[:earth_time]
 end
end

Instance Attribute Details

#earth_timeObject (readonly)

Returns the value of attribute earth_time.



61
62
63
# File 'lib/Vana/moon.rb', line 61

def earth_time
  @earth_time
end

Class Method Details

.now(listener = nil) ⇒ Object



36
37
38
39
40
# File 'lib/Vana/moon.rb', line 36

def self.now(listener=nil)
 opts = {:earth_time => Time.now}
 opts[:listener] = listener if listener
 self.new(opts)
end

Instance Method Details

#update_earth_time(time) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/Vana/moon.rb', line 42

def update_earth_time(time)
 raise "Input needs to be a Time object" if ! time.is_a? Time

 @earth_time = time
 set_moon_days
 set_percent
 set_phase
 set_moon_string
 set_optimal
end

#update_vana_time(vt) ⇒ Object



53
54
55
56
57
58
59
# File 'lib/Vana/moon.rb', line 53

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