Class: HangoutsJsonParser::Attachment::Photo
- Inherits:
-
Attachment
- Object
- Attachment
- HangoutsJsonParser::Attachment::Photo
- Defined in:
- lib/hangouts_json_parser/attachment/photo.rb
Overview
A photo attachment
Instance Attribute Summary collapse
-
#album ⇒ String
readonly
Album ID that the photo is in.
-
#id ⇒ String
readonly
Photo ID.
-
#photo_link ⇒ String
readonly
Link to the photo on Google+.
-
#thumbnail ⇒ String
readonly
URL to thumbnail of the image.
-
#url ⇒ String
readonly
URL of the image.
Class Method Summary collapse
-
.from_message_attachment(data) ⇒ Photo
Creates a Photo from message data.
-
.type ⇒ Array
Type identifier of this attachment.
Instance Method Summary collapse
-
#initialize(id, album, photo_link, thumbnail, url) ⇒ Photo
constructor
A new instance of Photo.
Constructor Details
#initialize(id, album, photo_link, thumbnail, url) ⇒ Photo
Returns a new instance of Photo.
16 17 18 19 20 21 22 |
# File 'lib/hangouts_json_parser/attachment/photo.rb', line 16 def initialize id, album, photo_link, thumbnail, url @album = album @id = id @photo_link = photo_link @thumbnail = thumbnail @url = url end |
Instance Attribute Details
#album ⇒ String (readonly)
Returns album ID that the photo is in.
8 9 10 |
# File 'lib/hangouts_json_parser/attachment/photo.rb', line 8 def album @album end |
#id ⇒ String (readonly)
Returns photo ID.
6 7 8 |
# File 'lib/hangouts_json_parser/attachment/photo.rb', line 6 def id @id end |
#photo_link ⇒ String (readonly)
Returns link to the photo on Google+.
10 11 12 |
# File 'lib/hangouts_json_parser/attachment/photo.rb', line 10 def photo_link @photo_link end |
#thumbnail ⇒ String (readonly)
Returns URL to thumbnail of the image.
12 13 14 |
# File 'lib/hangouts_json_parser/attachment/photo.rb', line 12 def thumbnail @thumbnail end |
#url ⇒ String (readonly)
Returns URL of the image.
14 15 16 |
# File 'lib/hangouts_json_parser/attachment/photo.rb', line 14 def url @url end |
Class Method Details
.from_message_attachment(data) ⇒ Photo
Creates a Photo from message data
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/hangouts_json_parser/attachment/photo.rb', line 27 def self. data raise "Attachment passed is not a photo" unless data.dig("embed_item", "type").eql? Photo.type photo = data.dig("embed_item", "embeds.PlusPhoto.plus_photo") raise "Photo data not found" if photo.nil? Photo.new photo["photo_id"], photo["album_id"], photo.dig("thumbnail", "url"), photo.dig("thumbnail", "image_url"), photo["url"] end |
.type ⇒ Array
Returns type identifier of this attachment.
41 42 43 |
# File 'lib/hangouts_json_parser/attachment/photo.rb', line 41 def self.type ["PLUS_PHOTO"] end |