class Cinch::Plugin::Cooldown

An alteration to the Plugin Module to allow for configurable cooldowns.

Attributes

duration[RW]
expires_at[RW]
time[RW]

Public Class Methods

new(duration, time = Time.now) click to toggle source
# File lib/cinch/plugin/cooldown.rb, line 7
def initialize(duration, time = Time.now)
  @time = time
  @duration = duration
  @expires_at = @time + @duration
end

Public Instance Methods

cooled_down?() click to toggle source
# File lib/cinch/plugin/cooldown.rb, line 24
def cooled_down?
  time_till_expire.zero?
end
time_till_expire() click to toggle source
# File lib/cinch/plugin/cooldown.rb, line 18
def time_till_expire
  period = @expires_at - Time.now
  return 0 if period < 0
  period
end
time_till_expire_in_words() click to toggle source
# File lib/cinch/plugin/cooldown.rb, line 13
def time_till_expire_in_words
  return 'until right now' if (expires_at - Time.now) < 0
  TimeLord::Period.new(expires_at, Time.now).to_words
end