Class: GooglePlaces::Photo

Inherits:
Object
  • Object
show all
Defined in:
lib/google_places/photo.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(width, height, photo_reference, html_attributions, api_key) ⇒ Photo

Returns a new instance of Photo.



5
6
7
8
9
10
11
# File 'lib/google_places/photo.rb', line 5

def initialize(width, height, photo_reference, html_attributions, api_key)
  @width             = width
  @height            = height
  @photo_reference   = photo_reference
  @html_attributions = html_attributions
  @api_key           = api_key
end

Instance Attribute Details

#heightObject

Returns the value of attribute height.



3
4
5
# File 'lib/google_places/photo.rb', line 3

def height
  @height
end

#html_attributionsObject

Returns the value of attribute html_attributions.



3
4
5
# File 'lib/google_places/photo.rb', line 3

def html_attributions
  @html_attributions
end

#photo_referenceObject

Returns the value of attribute photo_reference.



3
4
5
# File 'lib/google_places/photo.rb', line 3

def photo_reference
  @photo_reference
end

#widthObject

Returns the value of attribute width.



3
4
5
# File 'lib/google_places/photo.rb', line 3

def width
  @width
end

Instance Method Details

#fetch_url(maxwidth, options = {}) ⇒ URL

Search for a Photo’s url with its reference key

Parameters:

  • api_key (String)

    the provided api key

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :retry_options (Hash) — default: {}

    A Hash containing parameters for search retries

  • :retry_options[:status] (Object) — default: []
  • :retry_options[:max] (Integer) — default: 0

    the maximum retries

  • :retry_options[:delay] (Integer) — default: 5

    the delay between each retry in seconds

Returns:

  • (URL)


23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/google_places/photo.rb', line 23

def fetch_url(maxwidth, options = {})
  language  = options.delete(:language)
  retry_options = options.delete(:retry_options) || {}

  unless @fetched_url
    @fetched_url = Request.photo_url(
      :maxwidth => maxwidth,
      :photoreference => @photo_reference,
      :key => @api_key,
      :retry_options => retry_options
    )
  end
  @fetched_url
end