class Flickr::Object::Photo

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:

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.

Constants

SIZES

Public Instance Methods

add_tags(tags, params = {}) click to toggle source

@return [response] @see Flickr::Api::Photo#add_tags

# File lib/flickr/object/photo.rb, line 294
def add_tags(tags, params = {})
  api.add_tags(id, tags, params)
end
content_type=(content_type, params = {})
Alias for: set_content_type
delete(params = {}) click to toggle source

@return [response] @see Flickr::Api::Photo#delete

# File lib/flickr/object/photo.rb, line 268
def delete(params = {})
  api.delete(id, params)
end
get_exif!(params = {}) click to toggle source

@return [self] @see Flickr::Api::Photo#get_exif

# 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 = {}) click to toggle source

@return [Flickr::Object::List<Flickr::Object::Person>] @see Flickr::Api::Photo#get_favorites

# File lib/flickr/object/photo.rb, line 260
def get_favorites(params = {})
  api.get_favorites(id, params)
end
get_info!(params = {}) click to toggle source

@return [self] @see Flickr::Api::Photo#get_info

# 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 = {}) click to toggle source

@return [self] @see Flickr::Api::Photo#get_sizes

# File lib/flickr/object/photo.rb, line 242
def get_sizes!(params = {})
  photo = api.get_sizes(id, params)
  update(photo.attributes)
end
largest() click to toggle source

@return [self]

# File lib/flickr/object/photo.rb, line 212
def largest
  dup.largest!
end
largest!() click to toggle source

@return [self]

# File lib/flickr/object/photo.rb, line 205
def largest!
  size! largest_size
end
remove_tag(tag_or_id, params = {}) click to toggle source

@return [response] @see Flickr::Api::Photo#remove_tag

# 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 = {}) click to toggle source

@return [response] @see Flickr::Api::Photo#set_content_type

# File lib/flickr/object/photo.rb, line 276
def set_content_type(content_type, params = {})
  api.set_content_type(id, content_type, params)
end
Also aliased as: content_type=
set_dates(params = {}) click to toggle source

@return [response] @see Flickr::Api::Photo#set_dates

# File lib/flickr/object/photo.rb, line 310
def set_dates(params = {})
  api.set_dates(id, params)
end
set_license(license_id, params = {}) click to toggle source

@return [response] @see Flickr::Api::Photo#set_license

# 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 = {}) click to toggle source

@return [response] @see Flickr::Api::Photo#set_meta

# File lib/flickr/object/photo.rb, line 318
def set_meta(params = {})
  api.set_meta(id, params)
end
set_permissions(params = {}) click to toggle source

@return [response] @see Flickr::Api::Photo#set_permissions

# File lib/flickr/object/photo.rb, line 326
def set_permissions(params = {})
  api.set_permissions(id, params)
end
set_safety_level(params = {}) click to toggle source

@return [response] @see Flickr::Api::Photo#set_safety_level

# File lib/flickr/object/photo.rb, line 334
def set_safety_level(params = {})
  api.set_safety_level(id, params)
end
set_tags(tags, params = {}) click to toggle source

@return [response] @see Flickr::Api::Photo#set_tags

# File lib/flickr/object/photo.rb, line 285
def set_tags(tags, params = {})
  api.set_tags(id, tags, params)
end
Also aliased as: tags=
size() click to toggle source

The size of the photo, can be changed with modifer methods (see the definition of this class for details).

@return [String]

# File lib/flickr/object/photo.rb, line 127
def size
  @size.name if @size
end
size!(name) click to toggle source

Changes the size of the photo.

# File lib/flickr/object/photo.rb, line 219
def size!(name)
  if name != nil and not Size.exists?(name)
    raise ArgumentError, "\"#{name}\" isn't a valid photo size"
  end

  @size = Size.new(name)

  self
end
tags=(tags, params = {})
Alias for: set_tags