class Cinch::Plugins::PaxTimer
Cinch
Cooldown for PAX countdowns
Versioning info
Versioning info
Constants
- PAXES
- VERSION
Public Instance Methods
next_pax(m)
click to toggle source
# File lib/cinch/plugins/pax-timer.rb, line 17 def next_pax(m) m.reply get_next_pax end
Private Instance Methods
get_next_pax(type = nil)
click to toggle source
# File lib/cinch/plugins/pax-timer.rb, line 32 def get_next_pax(type = nil) @pax = get_next_pax_for(type) return 'I don\'t have info for the next one of those PAXes' if @pax.nil? message = ["#{@pax[:name]} is"] message << 'approximately' if @pax[:estimated] # Uncomment this once we can specify granularity in Time Lord. # message << TimeLord::Period.new(@pax[:date], Time.now).to_words message << Cinch::Toolbox.time_format(@pax[:date] - Time.now, [:days]) message << 'from now' message << ' (No official date, yet)' if @pax[:estimated] message.join(' ') end
get_next_pax_for(type)
click to toggle source
# File lib/cinch/plugins/pax-timer.rb, line 49 def get_next_pax_for(type) paxes = PAXES.dup paxes.delete_if { |pax| pax[:date] - Time.now < 0 } paxes.delete_if { |pax| pax[:type] != type } unless type.nil? paxes.sort! { |a, b| b[:date] <=> a[:date] } paxes.last end