Class: Google::Maps::Place

Inherits:
Object
  • Object
show all
Defined in:
lib/google_maps/place.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, keyword) ⇒ Place

Returns a new instance of Place.



12
13
14
15
16
# File 'lib/google_maps/place.rb', line 12

def initialize(data, keyword)
  @text = data.description
  @place_id = data.place_id
  @html = highligh_keywords(data, keyword)
end

Instance Attribute Details

#htmlObject (readonly) Also known as: to_html

Returns the value of attribute html.



8
9
10
# File 'lib/google_maps/place.rb', line 8

def html
  @html
end

#keywordObject (readonly)

Returns the value of attribute keyword.



8
9
10
# File 'lib/google_maps/place.rb', line 8

def keyword
  @keyword
end

#place_idObject (readonly)

Returns the value of attribute place_id.



8
9
10
# File 'lib/google_maps/place.rb', line 8

def place_id
  @place_id
end

#textObject (readonly) Also known as: to_s

Returns the value of attribute text.



8
9
10
# File 'lib/google_maps/place.rb', line 8

def text
  @text
end

Class Method Details

.find(keyword, language = :en) ⇒ Object



18
19
20
21
# File 'lib/google_maps/place.rb', line 18

def self.find(keyword, language = :en)
  args = { language: language, input: keyword }
  API.query(:places_service, args).predictions.map { |prediction| Place.new(prediction, keyword) }
end