Class: HotOrNot::ComparisonResult

Inherits:
Object
  • Object
show all
Defined in:
lib/hot-or-not/comparison_result.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(compare_url, side_a_results, side_b_results) ⇒ ComparisonResult

Returns a new instance of ComparisonResult.



18
19
20
21
22
# File 'lib/hot-or-not/comparison_result.rb', line 18

def initialize(compare_url, side_a_results, side_b_results)
  @compare_url, @side_a_results, @side_b_results = compare_url, side_a_results, side_b_results
  @message, @diff = '', ''
  init
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



16
17
18
# File 'lib/hot-or-not/comparison_result.rb', line 16

def message
  @message
end

Class Method Details

.for(compare_url) ⇒ Object



5
6
7
8
# File 'lib/hot-or-not/comparison_result.rb', line 5

def for(compare_url)
  headers = compare_url.headers
  new compare_url, retreive(compare_url.side_a, headers), retreive(compare_url.side_b, headers)
end

Instance Method Details

#diff(format = :text) ⇒ Object



36
37
38
# File 'lib/hot-or-not/comparison_result.rb', line 36

def diff(format = :text)
  @diff.to_s format
end

#output_to_files_in(directory) ⇒ Object



40
41
42
43
44
# File 'lib/hot-or-not/comparison_result.rb', line 40

def output_to_files_in(directory)
  write_to directory, "side_a", side_a_body
  write_to directory, "side_b", side_b_body
  write_to directory, "diff", diff
end

#side_a_bodyObject



28
29
30
# File 'lib/hot-or-not/comparison_result.rb', line 28

def side_a_body
  @side_a_body ||= body_by_content_type @side_a_results
end

#side_b_bodyObject



32
33
34
# File 'lib/hot-or-not/comparison_result.rb', line 32

def side_b_body
  @side_b_body ||= body_by_content_type @side_b_results
end

#success?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/hot-or-not/comparison_result.rb', line 24

def success?
  @success
end