Class: Atig::Command::Uptime
Instance Attribute Summary
Attributes inherited from Command
#api, #db, #gateway, #opts
Instance Method Summary
collapse
Methods inherited from Command
#find_by_tid
Constructor Details
#initialize(*args) ⇒ Uptime
Returns a new instance of Uptime.
8
9
10
11
|
# File 'lib/atig/command/uptime.rb', line 8
def initialize(*args)
super
@time = ::Time.now
end
|
Instance Method Details
#action(target, mesg, command, args) {|format(::Time.now - @time)| ... } ⇒ Object
15
16
17
|
# File 'lib/atig/command/uptime.rb', line 15
def action(target, mesg, command, args)
yield format(::Time.now - @time)
end
|
#command_name ⇒ Object
13
|
# File 'lib/atig/command/uptime.rb', line 13
def command_name; "uptime" end
|
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/atig/command/uptime.rb', line 19
def format(x)
day , y = x.divmod(60*60*24)
hour, z = y.divmod(60*60)
min , sec = z.divmod(60)
s = ""
s += "#{day} days " if day > 0
s += "%02d:" % hour if hour > 0
s += "%02d:%02d" % [min,sec]
s
end
|