Class: HotOrNot::InlineAnnouncer

Inherits:
Object
  • Object
show all
Includes:
Announcer
Defined in:
lib/hot_or_not/announcers/inline_announcer.rb

Instance Method Summary collapse

Constructor Details

#initialize(output_dir) ⇒ InlineAnnouncer

Returns a new instance of InlineAnnouncer.



5
6
7
8
9
# File 'lib/hot_or_not/announcers/inline_announcer.rb', line 5

def initialize(output_dir)
  @output_dir = output_dir
  @counts = Hash.new(0)
  @start = nil
end

Instance Method Details

#announce_error(result) ⇒ Object



36
37
38
39
40
# File 'lib/hot_or_not/announcers/inline_announcer.rb', line 36

def announce_error(result)
  @counts[:error] += 1
  say 'Error', result
  result.output_to_files_in results_dir
end

#announce_failure(result) ⇒ Object



30
31
32
33
34
# File 'lib/hot_or_not/announcers/inline_announcer.rb', line 30

def announce_failure(result)
  @counts[:failure] += 1
  say 'Not Hot', result
  result.output_to_files_in results_dir
end

#announce_success(result) ⇒ Object



25
26
27
28
# File 'lib/hot_or_not/announcers/inline_announcer.rb', line 25

def announce_success(result)
  @counts[:success] += 1
  say 'Hot', result
end

#endingObject



16
17
18
19
20
21
22
23
# File 'lib/hot_or_not/announcers/inline_announcer.rb', line 16

def ending
  completion_time = Time.now - @start
  total = @counts.values.reduce(:+)
  puts
  puts "Finished in %.6f seconds." % [completion_time]
  puts
  puts "#{total} body comparisons, #{@counts[:success]} hot bodies, #{@counts[:failure]} not-hot bodies, #{@counts[:error]} errored bodies"
end

#startingObject



11
12
13
14
# File 'lib/hot_or_not/announcers/inline_announcer.rb', line 11

def starting
  puts "Starting to compare the bodies"
  @start = Time.now
end