class Buryspam::Timer

A simple sleep timer which is used during poll mode to determine when we should connect to the IMAP server to download messages.

Attributes

sleep_sec[R]

Public Class Methods

new(event_time) click to toggle source

Convert the event_time to seconds. Event times are of the form "<num>(hr|min)".

# File buryspam.rb, line 579
def initialize(event_time)
  md = /\A(\d+)(hr|min)s?\z/.match(event_time)
  if md.nil?
    raise ArgumentError, "Invalid timer interval: '#{event_time}'"
  end
  @time = event_time
  num, units = $1.to_i, $2
  @sleep_sec = case units
                 when "hr"  then num * Stats::SECS_PER_HOUR
                 when "min" then num * Stats::SECS_PER_MINUTE
               end
end

Public Instance Methods

to_s() click to toggle source

Return the event_time value passed to the constructor.

# File buryspam.rb, line 593
def to_s
  @time
end
wait() click to toggle source

Sleep for the amount of time passed to the constructor.

# File buryspam.rb, line 598
def wait
  sleep @sleep_sec
end