Class: RWB::RunResults

Inherits:
Object
  • Object
show all
Defined in:
lib/rwb/results.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRunResults

Returns a new instance of RunResults.



19
20
21
# File 'lib/rwb/results.rb', line 19

def initialize
  @results = Array.new
end

Instance Attribute Details

#resultsObject (readonly)

Returns the value of attribute results.



17
18
19
# File 'lib/rwb/results.rb', line 17

def results
  @results
end

Instance Method Details

#add_result(result) ⇒ Object



23
24
25
# File 'lib/rwb/results.rb', line 23

def add_result(result)
  @results.push(result)
end

#all_by_response_code(code) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/rwb/results.rb', line 33

def all_by_response_code(code)
  coded_results = Array.new
  @results.each do |result|
    if result.response_code.to_i == code.to_i
      coded_results.push(result)
    end
  end
  coded_results
end

#all_by_url(url) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/rwb/results.rb', line 43

def all_by_url(url)
  coded_results = Array.new
  @results.each do |result|
    if result.url.to_s == url.to_s
      coded_results.push(result)
    end
  end
  coded_results
end

#all_with_idObject



59
60
61
62
63
64
65
# File 'lib/rwb/results.rb', line 59

def all_with_id
  id_results = Hash.new
  @results.each do |result|
    id_results[result.id] = result
  end
  id_results
end

#each_by_response_code(code) ⇒ Object



27
28
29
30
31
# File 'lib/rwb/results.rb', line 27

def each_by_response_code(code)
  @results.each do |result|
    yield result if result.response_code.to_i == code.to_i
  end
end

#each_by_url(url) ⇒ Object



53
54
55
56
57
# File 'lib/rwb/results.rb', line 53

def each_by_url(url)
  @results.each do |result|
    yield result if result.url.to_s == url.to_s
  end
end

#times_by_url(url = nil) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/rwb/results.rb', line 67

def times_by_url(url =  nil)
  coded_results = Array.new
  @results.each do |result|
    if url
      if result.url.to_s == url.to_s
        coded_results.push(result.elapsed_time)
      end
    else
        coded_results.push(result.elapsed_time)
    end          
  end
  coded_results
end