Class: PagespeedInsights::V5

Inherits:
Object
  • Object
show all
Defined in:
lib/v5/api_v5.rb

Overview

Wrapper for Pagespeed Insights API version 5

Constant Summary collapse

PAGESPEED_API_URL =
'https://www.googleapis.com/pagespeedonline/v5/runPagespeed'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url:, key:, strategy: nil, categories: []) ⇒ V5

Returns a new instance of V5.



11
12
13
14
15
16
17
# File 'lib/v5/api_v5.rb', line 11

def initialize(url:, key:, strategy: nil, categories: [])
  @base_url = PAGESPEED_API_URL
  @url = url
  @key = key
  @strategy = strategy
  @categories = categories
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



9
10
11
# File 'lib/v5/api_v5.rb', line 9

def body
  @body
end

#categoriesObject (readonly)

Returns the value of attribute categories.



9
10
11
# File 'lib/v5/api_v5.rb', line 9

def categories
  @categories
end

#headersObject (readonly)

Returns the value of attribute headers.



9
10
11
# File 'lib/v5/api_v5.rb', line 9

def headers
  @headers
end

#keyObject (readonly)

Returns the value of attribute key.



9
10
11
# File 'lib/v5/api_v5.rb', line 9

def key
  @key
end

#statusObject (readonly)

Returns the value of attribute status.



9
10
11
# File 'lib/v5/api_v5.rb', line 9

def status
  @status
end

#strategyObject (readonly)

Returns the value of attribute strategy.



9
10
11
# File 'lib/v5/api_v5.rb', line 9

def strategy
  @strategy
end

#urlObject (readonly)

Returns the value of attribute url.



9
10
11
# File 'lib/v5/api_v5.rb', line 9

def url
  @url
end

Instance Method Details

#results(fields: nil, pretty_print: true) ⇒ Object



19
20
21
22
23
# File 'lib/v5/api_v5.rb', line 19

def results(fields: nil, pretty_print: true)
  parse_categories
  uri_params = uri_params_generator(fields, pretty_print)
  make_request(uri_params)
end