Class: StopangoTester::Report

Inherits:
Struct
  • Object
show all
Defined in:
lib/stopango_tester/report.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#recordObject

Returns the value of attribute record

Returns:

  • (Object)

    the current value of record



5
6
7
# File 'lib/stopango_tester/report.rb', line 5

def record
  @record
end

#responseObject

Returns the value of attribute response

Returns:

  • (Object)

    the current value of response



5
6
7
# File 'lib/stopango_tester/report.rb', line 5

def response
  @response
end

Instance Method Details

#hashObject



21
22
23
# File 'lib/stopango_tester/report.rb', line 21

def hash
  @hash ||= Hash.new
end

#to_jsonObject

 field :named_fid  field :url  field :time, type: Float  field :status



11
12
13
14
15
16
17
18
19
# File 'lib/stopango_tester/report.rb', line 11

def to_json
  hash[:named_fid] = record.named_fid
  hash[:status] = response.code
  hash[:url] = ::CGI.escape(record.test_url)
  hash[:time] = response.time
  hash[:response] = response.body if error?
  hash[:tester_id] = record.tester_id
  hash
end

#to_sObject



25
26
27
28
29
# File 'lib/stopango_tester/report.rb', line 25

def to_s
"\nurl: #{URI.decode(hash[:url])}\n" +
" status: #{hash[:status]}\n" +
" time: #{hash[:time]}"
end