Class: FFXI::VanaTime
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
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Common
earth_to_vana, vana_to_earth
#add_listener, #has_listeners?, property, #remove_listener
Constructor Details
#initialize(opts = {}) ⇒ VanaTime
Returns a new instance of VanaTime.
13
14
15
16
17
|
# File 'lib/Vana/time.rb', line 13
def initialize(opts={})
super()
add_listener(opts[:listener]) if opts[:listener]
update_earth_time(opts[:earth_time]) if opts[:earth_time]
end
|
Class Method Details
.at(vt, listener = nil) ⇒ Object
19
20
21
22
23
|
# File 'lib/Vana/time.rb', line 19
def self.at(vt, listener = nil)
opts = {:earth_time => Time.at(FFXI::Common.vana_to_earth(vt))}
opts[:listener] = listener if listener
self.new(opts)
end
|
.now(listener = nil) ⇒ Object
25
26
27
28
29
|
# File 'lib/Vana/time.rb', line 25
def self.now(listener = nil)
opts = {:earth_time => Time.now}
opts[:listener] = listener if listener
self.new(opts)
end
|
Instance Method Details
#to_f ⇒ Object
49
50
51
|
# File 'lib/Vana/time.rb', line 49
def to_f
vana_time.to_f
end
|
#to_i ⇒ Object
45
46
47
|
# File 'lib/Vana/time.rb', line 45
def to_i
vana_time.to_i
end
|
#to_s ⇒ Object
53
54
55
|
# File 'lib/Vana/time.rb', line 53
def to_s
"#{date_string} #{time_string}"
end
|
#update_earth_time(time) ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/Vana/time.rb', line 31
def update_earth_time(time)
raise "input needs to be a Time object" if ! time.is_a? Time
self.earth_time = time
self.earth_time_string = time.to_s
vt = FFXI::Common.earth_to_vana(time)
set_properties(vt)
end
|
#update_vana_time(vt) ⇒ Object
39
40
41
42
43
|
# File 'lib/Vana/time.rb', line 39
def update_vana_time(vt)
self.earth_time = Time.at(FFXI::Common.vana_to_earth(vt))
self.earth_time_string = earth_time.to_s
set_properties(vt)
end
|