Class: Susuwatari::Client

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/susuwatari/client.rb

Constant Summary collapse

TEST_URL =
'http://www.webpagetest.org/runtest.php'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Client

Returns a new instance of Client.



11
12
13
14
15
16
17
18
# File 'lib/susuwatari/client.rb', line 11

def initialize( params = {} )
  params.fetch(:k)
  params.fetch(:url)
  params[:f] = :json
  params[:runs] ||= 1
  params.delete(:r)
  self.params = params
end

Instance Attribute Details

#paramsObject

Returns the value of attribute params.



5
6
7
# File 'lib/susuwatari/client.rb', line 5

def params
  @params
end

#responseObject

Returns the value of attribute response.



5
6
7
# File 'lib/susuwatari/client.rb', line 5

def response
  @response
end

Instance Method Details

#resultObject



26
27
28
# File 'lib/susuwatari/client.rb', line 26

def result
  @result && @result.test_result || {}
end

#runObject



20
21
22
23
24
# File 'lib/susuwatari/client.rb', line 20

def run
  return status if @result
  @result = Result.new(make_request)
  @result.test_id
end

#statusObject



30
31
32
# File 'lib/susuwatari/client.rb', line 30

def status
  @result && @result.status || :to_be_run
end