Class: Flickr::Object::Photo
- Inherits:
-
Flickr::Object
- Object
- Flickr::Object
- Flickr::Object::Photo
- Defined in:
- lib/flickr/object/photo.rb,
lib/flickr/object/photo/tag.rb,
lib/flickr/object/photo/exif.rb,
lib/flickr/object/photo/note.rb,
lib/flickr/object/photo/size.rb,
lib/flickr/object/attribute_locations/photo.rb,
lib/flickr/object/attribute_locations/photo/tag.rb,
lib/flickr/object/attribute_locations/photo/exif.rb,
lib/flickr/object/attribute_locations/photo/note.rb
Overview
Probably the most important class in this library.
## Sizes
It has an interface for assigning the photo’s size. Current Flickr’s photo sizes are:
-
Square 75/150
-
Thumbnail
-
Medium 500/640/800
-
Large 1024/1600/2048
-
Original
Important: When fetching photos, the information about the sizes (URL, width, height) isn’t automatically available. If you’re fetching multiple photos (e.g. using ‘Flickr.photos.search`), you need to pass `:sizes => true`. For individual photos, use #get_sizes.
Any of the following ways will change the photo’s size to “Medium 500”:
photo.medium500!
photo.medium!(500)
photo.medium!("500")
A change to photo’s size affects the following attributes: #source_url, #width and #height.
You may often just want to assign the largest possible size to the photo:
photo.largest!
You may also want to assign the largest size to the photo, but that it’s not larger/smaller than “Medium 500”:
photo.medium500_or_smaller!
photo.medium500_at_least!
Note: The corresponding non-bang versions of the methods are also available:
photo.medium500
photo.medium(500)
photo.medium("500")
photo.largest
photo.medium500_or_smaller
photo.medium500_at_least
However, these are not recommended, since they duplicate the photo, taking up twice as much memory. Use them only if you really have to.
Defined Under Namespace
Classes: Exif, Note, Size, Tag
Constant Summary collapse
- SIZES =
[ "Square 75", "Thumbnail", "Square 150", "Small 240", "Small 320", "Medium 500", "Medium 640", "Medium 800", "Large 1024", "Large 1600", "Large 2048", "Original", ]
Instance Attribute Summary collapse
- #available_sizes ⇒ Array[String] readonly
- #camera ⇒ String readonly
- #comments_count ⇒ Integer readonly
- #description ⇒ String readonly
- #editability ⇒ Permissions readonly
- #exif ⇒ Exif readonly
- #farm ⇒ Integer readonly
- #favorite ⇒ Boolean readonly
- #has_people ⇒ Boolean readonly
- #height ⇒ Integer readonly
- #id ⇒ String readonly
- #largest_size ⇒ String readonly
- #license ⇒ Integer readonly
- #location ⇒ Location readonly
- #location_visibility ⇒ Visibility readonly
- #moderate ⇒ Boolean readonly
- #notes ⇒ List[Note] readonly
- #owner ⇒ Person readonly
- #path_alias ⇒ String readonly
- #posted_at ⇒ Time readonly
- #public_editability ⇒ Permissions readonly
- #restricted ⇒ Boolean readonly
- #rotation ⇒ Integer readonly
- #safe ⇒ Boolean readonly
- #safety_level ⇒ Integer readonly
- #secret ⇒ String readonly
- #server ⇒ String readonly
- #short_url ⇒ String readonly
- #source_url ⇒ String readonly
- #tags ⇒ List[Tag] readonly
- #taken_at ⇒ Time readonly
- #taken_at_granularity ⇒ Integer readonly
- #title ⇒ String readonly
- #updated_at ⇒ Time readonly
- #uploaded_at ⇒ Time readonly
- #url ⇒ String readonly
- #usage ⇒ Permissions readonly
- #views_count ⇒ Integer readonly
- #visibility ⇒ Visibility readonly
- #width ⇒ Integer readonly
Attributes inherited from Flickr::Object
Instance Method Summary collapse
- #add_tags(tags, params = {}) ⇒ response
- #delete(params = {}) ⇒ response
- #get_exif!(params = {}) ⇒ self
- #get_favorites(params = {}) ⇒ Flickr::Object::List<Flickr::Object::Person>
- #get_info!(params = {}) ⇒ self
- #get_sizes!(params = {}) ⇒ self
- #largest ⇒ self
- #largest! ⇒ self
- #remove_tag(tag_or_id, params = {}) ⇒ response
- #set_content_type(content_type, params = {}) ⇒ response (also: #content_type=)
- #set_dates(params = {}) ⇒ response
- #set_license(license_id, params = {}) ⇒ response
- #set_meta(params = {}) ⇒ response
- #set_permissions(params = {}) ⇒ response
- #set_safety_level(params = {}) ⇒ response
- #set_tags(tags, params = {}) ⇒ response (also: #tags=)
-
#size ⇒ String
The size of the photo, can be changed with modifer methods (see the definition of this class for details).
-
#size!(name) ⇒ Object
Changes the size of the photo.
Methods inherited from Flickr::Object
#==, #[], attribute, #initialize, #inspect, #matches?, #update
Methods included from Attributes
Methods included from AutoloadHelper
#autoload_dir, #autoload_names
Constructor Details
This class inherits a constructor from Flickr::Object
Instance Attribute Details
#available_sizes ⇒ Array[String] (readonly)
106 |
# File 'lib/flickr/object/photo.rb', line 106 attribute :available_sizes, Array[String] |
#camera ⇒ String (readonly)
93 |
# File 'lib/flickr/object/photo.rb', line 93 attribute :camera, String |
#comments_count ⇒ Integer (readonly)
84 |
# File 'lib/flickr/object/photo.rb', line 84 attribute :comments_count, Integer |
#description ⇒ String (readonly)
63 |
# File 'lib/flickr/object/photo.rb', line 63 attribute :description, String |
#editability ⇒ Permissions (readonly)
86 |
# File 'lib/flickr/object/photo.rb', line 86 attribute :editability, Permissions |
#farm ⇒ Integer (readonly)
61 |
# File 'lib/flickr/object/photo.rb', line 61 attribute :farm, Integer |
#favorite ⇒ Boolean (readonly)
97 |
# File 'lib/flickr/object/photo.rb', line 97 attribute :favorite, Boolean |
#has_people ⇒ Boolean (readonly)
96 |
# File 'lib/flickr/object/photo.rb', line 96 attribute :has_people, Boolean |
#height ⇒ Integer (readonly)
110 |
# File 'lib/flickr/object/photo.rb', line 110 attribute :height, Integer |
#id ⇒ String (readonly)
58 |
# File 'lib/flickr/object/photo.rb', line 58 attribute :id, String |
#largest_size ⇒ String (readonly)
107 |
# File 'lib/flickr/object/photo.rb', line 107 attribute :largest_size, String |
#license ⇒ Integer (readonly)
64 |
# File 'lib/flickr/object/photo.rb', line 64 attribute :license, Integer |
#location ⇒ Location (readonly)
101 |
# File 'lib/flickr/object/photo.rb', line 101 attribute :location, Location |
#location_visibility ⇒ Visibility (readonly)
102 |
# File 'lib/flickr/object/photo.rb', line 102 attribute :location_visibility, Visibility |
#moderate ⇒ Boolean (readonly)
69 |
# File 'lib/flickr/object/photo.rb', line 69 attribute :moderate, Boolean |
#notes ⇒ List[Note] (readonly)
90 |
# File 'lib/flickr/object/photo.rb', line 90 attribute :notes, List[Note] |
#path_alias ⇒ String (readonly)
99 |
# File 'lib/flickr/object/photo.rb', line 99 attribute :path_alias, String |
#posted_at ⇒ Time (readonly)
78 |
# File 'lib/flickr/object/photo.rb', line 78 attribute :posted_at, Time |
#public_editability ⇒ Permissions (readonly)
87 |
# File 'lib/flickr/object/photo.rb', line 87 attribute :public_editability, Permissions |
#restricted ⇒ Boolean (readonly)
70 |
# File 'lib/flickr/object/photo.rb', line 70 attribute :restricted, Boolean |
#rotation ⇒ Integer (readonly)
104 |
# File 'lib/flickr/object/photo.rb', line 104 attribute :rotation, Integer |
#safety_level ⇒ Integer (readonly)
67 |
# File 'lib/flickr/object/photo.rb', line 67 attribute :safety_level, Integer |
#secret ⇒ String (readonly)
59 |
# File 'lib/flickr/object/photo.rb', line 59 attribute :secret, String |
#server ⇒ String (readonly)
60 |
# File 'lib/flickr/object/photo.rb', line 60 attribute :server, String |
#short_url ⇒ String (readonly)
73 |
# File 'lib/flickr/object/photo.rb', line 73 attribute :short_url, String |
#source_url ⇒ String (readonly)
109 |
# File 'lib/flickr/object/photo.rb', line 109 attribute :source_url, String |
#tags ⇒ List[Tag] (readonly)
91 |
# File 'lib/flickr/object/photo.rb', line 91 attribute :tags, List[Tag] |
#taken_at ⇒ Time (readonly)
79 |
# File 'lib/flickr/object/photo.rb', line 79 attribute :taken_at, Time |
#taken_at_granularity ⇒ Integer (readonly)
80 |
# File 'lib/flickr/object/photo.rb', line 80 attribute :taken_at_granularity, Integer |
#title ⇒ String (readonly)
62 |
# File 'lib/flickr/object/photo.rb', line 62 attribute :title, String |
#updated_at ⇒ Time (readonly)
81 |
# File 'lib/flickr/object/photo.rb', line 81 attribute :updated_at, Time |
#uploaded_at ⇒ Time (readonly)
77 |
# File 'lib/flickr/object/photo.rb', line 77 attribute :uploaded_at, Time |
#url ⇒ String (readonly)
72 |
# File 'lib/flickr/object/photo.rb', line 72 attribute :url, String |
#usage ⇒ Permissions (readonly)
88 |
# File 'lib/flickr/object/photo.rb', line 88 attribute :usage, Permissions |
#views_count ⇒ Integer (readonly)
83 |
# File 'lib/flickr/object/photo.rb', line 83 attribute :views_count, Integer |
#visibility ⇒ Visibility (readonly)
65 |
# File 'lib/flickr/object/photo.rb', line 65 attribute :visibility, Visibility |
#width ⇒ Integer (readonly)
111 |
# File 'lib/flickr/object/photo.rb', line 111 attribute :width, Integer |
Instance Method Details
#add_tags(tags, params = {}) ⇒ response
294 295 296 |
# File 'lib/flickr/object/photo.rb', line 294 def (, params = {}) api.(id, , params) end |
#delete(params = {}) ⇒ response
268 269 270 |
# File 'lib/flickr/object/photo.rb', line 268 def delete(params = {}) api.delete(id, params) end |
#get_exif!(params = {}) ⇒ self
251 252 253 254 |
# File 'lib/flickr/object/photo.rb', line 251 def get_exif!(params = {}) photo = api.get_exif(id, params) update(photo.attributes) end |
#get_favorites(params = {}) ⇒ Flickr::Object::List<Flickr::Object::Person>
260 261 262 |
# File 'lib/flickr/object/photo.rb', line 260 def get_favorites(params = {}) api.get_favorites(id, params) end |
#get_info!(params = {}) ⇒ self
233 234 235 236 |
# File 'lib/flickr/object/photo.rb', line 233 def get_info!(params = {}) photo = api.get_info(id, params) update(photo.attributes) end |
#get_sizes!(params = {}) ⇒ self
242 243 244 245 |
# File 'lib/flickr/object/photo.rb', line 242 def get_sizes!(params = {}) photo = api.get_sizes(id, params) update(photo.attributes) end |
#largest ⇒ self
212 213 214 |
# File 'lib/flickr/object/photo.rb', line 212 def largest dup.largest! end |
#largest! ⇒ self
205 206 207 |
# File 'lib/flickr/object/photo.rb', line 205 def largest! size! largest_size end |
#remove_tag(tag_or_id, params = {}) ⇒ response
302 303 304 |
# File 'lib/flickr/object/photo.rb', line 302 def remove_tag(tag_or_id, params = {}) api.remove_tag(id, tag_or_id, params) end |
#set_content_type(content_type, params = {}) ⇒ response Also known as: content_type=
276 277 278 |
# File 'lib/flickr/object/photo.rb', line 276 def set_content_type(content_type, params = {}) api.set_content_type(id, content_type, params) end |
#set_dates(params = {}) ⇒ response
310 311 312 |
# File 'lib/flickr/object/photo.rb', line 310 def set_dates(params = {}) api.set_dates(id, params) end |
#set_license(license_id, params = {}) ⇒ response
342 343 344 |
# File 'lib/flickr/object/photo.rb', line 342 def set_license(license_id, params = {}) api.set_license(id, license_id, params) end |
#set_meta(params = {}) ⇒ response
318 319 320 |
# File 'lib/flickr/object/photo.rb', line 318 def (params = {}) api.(id, params) end |
#set_permissions(params = {}) ⇒ response
326 327 328 |
# File 'lib/flickr/object/photo.rb', line 326 def (params = {}) api.(id, params) end |
#set_safety_level(params = {}) ⇒ response
334 335 336 |
# File 'lib/flickr/object/photo.rb', line 334 def set_safety_level(params = {}) api.set_safety_level(id, params) end |
#set_tags(tags, params = {}) ⇒ response Also known as:
285 286 287 |
# File 'lib/flickr/object/photo.rb', line 285 def (, params = {}) api.(id, , params) end |
#size ⇒ String
The size of the photo, can be changed with modifer methods (see the definition of this class for details).
127 128 129 |
# File 'lib/flickr/object/photo.rb', line 127 def size @size.name if @size end |