Class: HotOrNot::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/hot_or_not/runner.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(urls, announcer) ⇒ Runner

Returns a new instance of Runner.



7
8
9
# File 'lib/hot_or_not/runner.rb', line 7

def initialize(urls, announcer)
  @urls, @announcer = urls, announcer
end

Class Method Details

.run_from(file, announcer) ⇒ Object



3
4
5
# File 'lib/hot_or_not/runner.rb', line 3

def self.run_from(file, announcer)
  new CompareUrl.load_from(file), announcer
end

Instance Method Details

#run!(to_run = :all) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/hot_or_not/runner.rb', line 11

def run!(to_run = :all)
  @to_run = to_run
  @announcer.starting
  @urls.each do |url|
    next unless should_run? url
    result = ComparisonResult.for url
    if result.success?
      @announcer.announce_success result
    elsif result.error?
      @announcer.announce_error result
    else
      @announcer.announce_failure result
    end
  end
  @announcer.ending
end