Class: Kudzu::Agent::Sleeper

Inherits:
Object
  • Object
show all
Defined in:
lib/kudzu/agent/sleeper.rb

Instance Method Summary collapse

Constructor Details

#initialize(config, robots = nil) ⇒ Sleeper

Returns a new instance of Sleeper.


4
5
6
7
8
9
# File 'lib/kudzu/agent/sleeper.rb', line 4

def initialize(config, robots = nil)
  @config = config
  @robots = robots
  @monitor = Monitor.new
  @last_accessed = {}
end

Instance Method Details

#politeness_delay(uri) ⇒ Object


11
12
13
14
15
16
17
18
# File 'lib/kudzu/agent/sleeper.rb', line 11

def politeness_delay(uri)
  uri = Addressable::URI.parse(uri) if uri.is_a?(String)
  delay_sec = delay_second(uri)
  return unless delay_sec

  sleep_sec = sleep_second(uri, delay_sec)
  sleep sleep_sec if sleep_sec > 0
end