Class: GoogleMapsPlatform::PlacePhoto
- Defined in:
- lib/google_maps_platform/models/place_photo.rb
Overview
A photo of a Place. The photo can be accesed via the [Place Photo](developers.google.com/places/web-service/photos) API using an url in the following pattern: “‘ maps.googleapis.com/maps/api/place/photo?maxwidth=400&photo_referenc e=photo_reference&key=YOUR_API_KEY “` See [Place Photos](developers.google.com/places/web-service/photos) for more information.
Instance Attribute Summary collapse
-
#height ⇒ Float
The height of the photo.
-
#html_attributions ⇒ Array[String]
The HTML attributions for the photo.
-
#photo_reference ⇒ String
A string used to identify the photo when you perform a Photo request.
-
#width ⇒ Float
The width of the photo.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(height:, width:, html_attributions:, photo_reference:, additional_properties: nil) ⇒ PlacePhoto
constructor
A new instance of PlacePhoto.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(height:, width:, html_attributions:, photo_reference:, additional_properties: nil) ⇒ PlacePhoto
Returns a new instance of PlacePhoto.
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/google_maps_platform/models/place_photo.rb', line 54 def initialize(height:, width:, html_attributions:, photo_reference:, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @height = height @width = width @html_attributions = html_attributions @photo_reference = photo_reference @additional_properties = additional_properties end |
Instance Attribute Details
#height ⇒ Float
The height of the photo.
20 21 22 |
# File 'lib/google_maps_platform/models/place_photo.rb', line 20 def height @height end |
#html_attributions ⇒ Array[String]
The HTML attributions for the photo.
28 29 30 |
# File 'lib/google_maps_platform/models/place_photo.rb', line 28 def html_attributions @html_attributions end |
#photo_reference ⇒ String
A string used to identify the photo when you perform a Photo request.
32 33 34 |
# File 'lib/google_maps_platform/models/place_photo.rb', line 32 def photo_reference @photo_reference end |
#width ⇒ Float
The width of the photo.
24 25 26 |
# File 'lib/google_maps_platform/models/place_photo.rb', line 24 def width @width end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/google_maps_platform/models/place_photo.rb', line 67 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. height = hash.key?('height') ? hash['height'] : nil width = hash.key?('width') ? hash['width'] : nil html_attributions = hash.key?('html_attributions') ? hash['html_attributions'] : nil photo_reference = hash.key?('photo_reference') ? hash['photo_reference'] : nil # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. PlacePhoto.new(height: height, width: width, html_attributions: html_attributions, photo_reference: photo_reference, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
35 36 37 38 39 40 41 42 |
# File 'lib/google_maps_platform/models/place_photo.rb', line 35 def self.names @_hash = {} if @_hash.nil? @_hash['height'] = 'height' @_hash['width'] = 'width' @_hash['html_attributions'] = 'html_attributions' @_hash['photo_reference'] = 'photo_reference' @_hash end |
.nullables ⇒ Object
An array for nullable fields
50 51 52 |
# File 'lib/google_maps_platform/models/place_photo.rb', line 50 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
45 46 47 |
# File 'lib/google_maps_platform/models/place_photo.rb', line 45 def self.optionals [] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
102 103 104 105 106 107 |
# File 'lib/google_maps_platform/models/place_photo.rb', line 102 def inspect class_name = self.class.name.split('::').last "<#{class_name} height: #{@height.inspect}, width: #{@width.inspect}, html_attributions:"\ " #{@html_attributions.inspect}, photo_reference: #{@photo_reference.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
94 95 96 97 98 99 |
# File 'lib/google_maps_platform/models/place_photo.rb', line 94 def to_s class_name = self.class.name.split('::').last "<#{class_name} height: #{@height}, width: #{@width}, html_attributions:"\ " #{@html_attributions}, photo_reference: #{@photo_reference}, additional_properties:"\ " #{@additional_properties}>" end |