Class: Wayfarer::CrawlObserver

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/wayfarer/crawl_observer.rb

Defined Under Namespace

Modules: Events, ObservableShortcuts

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*observables, logger) ⇒ CrawlObserver

Returns a new instance of CrawlObserver.


29
30
31
32
# File 'lib/wayfarer/crawl_observer.rb', line 29

def initialize(*observables, logger)
  @logger = logger
  observables.each { |obsv| obsv.add_observer(self) }
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger


27
28
29
# File 'lib/wayfarer/crawl_observer.rb', line 27

def logger
  @logger
end

Instance Method Details

#update(event) ⇒ Object


34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/wayfarer/crawl_observer.rb', line 34

def update(event)
  case event
  when Events::FirstCycle     then first_cycle(event)
  when Events::NewCycle       then new_cycle(event)
  when Events::DispatchedURI  then dispatched_uri(event)
  when Events::CycleFinished  then cycle_finished
  when Events::Peeking        then peeking(event)
  when Events::AboutToCycle   then about_to_cycle(event)
  when Events::MismatchedURI  then mismatched_uri(event)
  when Events::HaltInitiated  then halt_initiated(event)
  when Events::StagingURIs    then staging_uris(event)
  when Events::UnhandledError then unhandled_error(event)
  end
end