Class: Fleakr::Objects::Photo
- Inherits:
-
Object
- Object
- Fleakr::Objects::Photo
- Extended by:
- Forwardable
- Includes:
- Support::Object
- Defined in:
- lib/fleakr/objects/photo.rb
Overview
Photo
Handles both the retrieval of Photo objects from various associations (e.g. User / Set) as well as the ability to upload images to the Flickr site.
Attributes
- id
-
The ID for this photo
- title
-
The title of this photo
- description
-
The description of this photo
- secret
-
This photo’s secret (used for sharing photo without permissions checking)
- original_secret
-
This photo’s original secret
- comment_count
-
Count of the comments attached to this photo
- url
-
This photo’s page on Flickr
- square
-
The tiny square representation of this photo
- thumbnail
-
The thumbnail for this photo
- small
-
The small representation of this photo
- medium
-
The medium representation of this photo
- large
-
The large representation of this photo
- original
-
The original photo
- previous
-
The previous photo based on the current context
- next
-
The next photo based on the current context
Associations
- images
-
The underlying images for this photo.
- tags
-
The tags for this photo.
- comments
-
The comments associated with this photo
Constant Summary collapse
- SIZES =
Available sizes for this photo
[:square, :thumbnail, :small, :medium, :large, :original]
Class Method Summary collapse
-
.upload(filename, options = {}) ⇒ Object
Upload the photo specified by
filename
to the user’s Flickr account.
Instance Method Summary collapse
-
#context ⇒ Object
:nodoc:.
-
#load_info ⇒ Object
TODO: Refactor this to remove duplication w/ User#load_info - possibly in the lazily_load class method.
- #metadata ⇒ Object
-
#owner ⇒ Object
The user who uploaded this photo.
-
#posted_at ⇒ Object
When was this photo posted?.
-
#replace_with(filename) ⇒ Object
Replace the current photo’s image with the one specified by filename.
-
#taken_at ⇒ Object
When was this photo taken?.
-
#updated_at ⇒ Object
When was this photo last updated? This includes addition of tags and other metadata.
Methods included from Support::Object
Class Method Details
.upload(filename, options = {}) ⇒ Object
Upload the photo specified by filename
to the user’s Flickr account. When uploading, there are several options available (none are required):
- :title
-
The title for this photo. Any string is allowed.
- :description
-
The description for this photo. Any string is allowed.
- :tags
-
A collection of tags for this photo. This can be a string or array of strings.
- :viewable_by
-
Who can view this photo? Acceptable values are one of
:everyone
,:friends
or:family
. This can also take an array of values (e.g.[:friends, :family]
) to make it viewable by friends and family. - :level
-
The safety level of this photo. Acceptable values are one of
:safe
,:moderate
, or:restricted
. - :type
-
The type of image this is. Acceptable values are one of
:photo
,:screenshot
, or:other
. - :hide?
-
Should this photo be hidden from public searches? Takes a boolean.
86 87 88 89 90 |
# File 'lib/fleakr/objects/photo.rb', line 86 def self.upload(filename, = {}) response = Fleakr::Api::UploadRequest.with_response!(filename, :create, ) photo = Photo.new(response.body) Photo.find_by_id(photo.id) end |
Instance Method Details
#context ⇒ Object
:nodoc:
107 108 109 110 111 112 |
# File 'lib/fleakr/objects/photo.rb', line 107 def context # :nodoc: @context ||= begin response = Fleakr::Api::MethodRequest.with_response!('photos.getContext', :photo_id => self.id) PhotoContext.new(response.body) end end |
#load_info ⇒ Object
TODO: Refactor this to remove duplication w/ User#load_info - possibly in the lazily_load class method
102 103 104 105 |
# File 'lib/fleakr/objects/photo.rb', line 102 def load_info # :nodoc: response = Fleakr::Api::MethodRequest.with_response!('photos.getInfo', :photo_id => self.id) self.populate_from(response.body) end |
#metadata ⇒ Object
67 68 69 |
# File 'lib/fleakr/objects/photo.rb', line 67 def @metadata ||= MetadataCollection.new(self) end |
#owner ⇒ Object
The user who uploaded this photo. See Fleakr::Objects::User for additional information.
116 117 118 |
# File 'lib/fleakr/objects/photo.rb', line 116 def owner @owner ||= User.find_by_id(owner_id) end |
#posted_at ⇒ Object
When was this photo posted?
122 123 124 |
# File 'lib/fleakr/objects/photo.rb', line 122 def posted_at Time.at(posted.to_i) end |
#replace_with(filename) ⇒ Object
Replace the current photo’s image with the one specified by filename. This call requires authentication.
95 96 97 98 99 |
# File 'lib/fleakr/objects/photo.rb', line 95 def replace_with(filename) response = Fleakr::Api::UploadRequest.with_response!(filename, :update, :photo_id => self.id) self.populate_from(response.body) self end |
#taken_at ⇒ Object
When was this photo taken?
128 129 130 |
# File 'lib/fleakr/objects/photo.rb', line 128 def taken_at Time.parse(taken) end |
#updated_at ⇒ Object
When was this photo last updated? This includes addition of tags and other metadata.
134 135 136 |
# File 'lib/fleakr/objects/photo.rb', line 134 def updated_at Time.at(updated.to_i) end |