Parent

Net::Flickr::Photo

A Flickr photo.

Don't instantiate this class yourself. Use the methods in Flickr::Photos to retrieve photos from Flickr.

Constants

SIZE_SUFFIX

Attributes

farm[R]
id[R]
secret[R]
server[R]

Public Class Methods

new(flickr, photo_xml) click to toggle source
# File lib/net/flickr/photo.rb, line 51
def initialize(flickr, photo_xml)
  @flickr = flickr
  
  parse_xml(photo_xml)
  
  # Detailed photo info.

  @context_xml = nil
  @info_xml    = nil
end

Public Instance Methods

delete() click to toggle source

Deletes this photo from Flickr. This method requires authentication with delete permission.

# File lib/net/flickr/photo.rb, line 63
def delete
  @flickr.photos.delete(@id)
end
description() click to toggle source

Gets this photo's description.

# File lib/net/flickr/photo.rb, line 68
def description
  info_xml = get_info
  return info_xml.at('description').inner_text
end
description=(value) click to toggle source

Sets this photo's description. This method requires authentication with write permission.

# File lib/net/flickr/photo.rb, line 75
def description=(value)
  set_meta(@title, value)
end
exif() click to toggle source

flickr.photos.getExif

# File lib/net/flickr/photo.rb, line 80
def exif
  raise NotImplementedError
end
family?() click to toggle source

Whether or not this photo is visible to family.

# File lib/net/flickr/photo.rb, line 85
def family?
  get_info if @is_family.nil?
  return @is_family || @is_public
end
favorites() click to toggle source

flickr.photos.getFavorites

# File lib/net/flickr/photo.rb, line 91
def favorites
  raise NotImplementedError
end
friend?() click to toggle source

Whether or not this photo is visible to friends.

# File lib/net/flickr/photo.rb, line 96
def friend?
  get_info if @is_friend.nil?
  return @is_friend || @is_public
end
gps() click to toggle source

flickr.photos.getExif

# File lib/net/flickr/photo.rb, line 102
def gps
  raise NotImplementedError
end
modified() click to toggle source

Gets the time this photo was last modified.

# File lib/net/flickr/photo.rb, line 107
def modified
  info_xml = get_info
  return Time.at(info_xml.at('dates')[:lastupdate].to_i)
end
next() click to toggle source

Gets the next photo in the owner's photo stream, or nil if this is the last photo in the stream.

# File lib/net/flickr/photo.rb, line 114
def next
  context_xml = get_context
  next_xml    = context_xml.at('nextphoto')
  
  return Photo.new(@flickr, next_xml) if next_xml[:id] != '0'
  return nil
end
owner() click to toggle source

Gets the user id of this photo's owner.

# File lib/net/flickr/photo.rb, line 123
def owner
  @owner
end
page_url() click to toggle source

Gets the URL of this photo's Flickr photo page.

# File lib/net/flickr/photo.rb, line 128
def page_url
  return "http://www.flickr.com/photos/#{@owner}/#{@id}"
end
pools() click to toggle source

flickr.photos.getAllContexts

# File lib/net/flickr/photo.rb, line 133
def pools
  raise NotImplementedError
end
posted() click to toggle source

Gets the time this photo was posted to Flickr.

# File lib/net/flickr/photo.rb, line 138
def posted
  info_xml = get_info
  return Time.at(info_xml.at('dates')[:posted].to_i)
end
posted=(time) click to toggle source

flickr.photos.setDates

# File lib/net/flickr/photo.rb, line 144
def posted=(time)
end
prev() click to toggle source
Alias for: previous
previous() click to toggle source

Gets the previous photo in the owner's photo stream, or nil if this is the first photo in the stream.

# File lib/net/flickr/photo.rb, line 149
def previous
  context_xml = get_context
  prev_xml = context_xml.at('prevphoto')
  
  return Photo.new(@flickr, prev_xml) if prev_xml[:id] != '0'
  return nil
end
Also aliased as: prev
public?() click to toggle source

Whether or not this photo is visible to the general public.

# File lib/net/flickr/photo.rb, line 160
def public?
  get_info if @is_public.nil?
  return @is_public
end
sets() click to toggle source

flickr.photos.getAllContexts

# File lib/net/flickr/photo.rb, line 166
def sets
  raise NotImplementedError
end
sizes() click to toggle source

flickr.photos.getSizes

# File lib/net/flickr/photo.rb, line 171
def sizes
  raise NotImplementedError
end
source_url(size = :medium) click to toggle source

Gets the source URL for this photo at one of the following specified sizes. Returns nil if the specified size is not available.

:square

75x75px

:thumb

100px on longest side

:small

240px on longest side

:medium

500px on longest side

:large

1024px on longest side (not available for all images)

:original

original image in original file format

# File lib/net/flickr/photo.rb, line 184
def source_url(size = :medium)
  suffix = SIZE_SUFFIX[size]
  
  case size
    when :medium
      return "http://farm#{@farm}.static.flickr.com/#{@server}/#{@id}_" +
          "#{@secret}.jpg"
    
    when :original
      info_xml = get_info
      
      original_secret = info_xml[:originalsecret]
      original_format = info_xml[:originalformat]
      
      return nil if original_secret.nil? || original_format.nil? 
      return "http://farm#{@farm}.static.flickr.com/#{@server}/#{@id}_" +
          "#{original_secret}_o.#{original_format}"

    else
      return "http://farm#{@farm}.static.flickr.com/#{@server}/#{@id}_" +
          "#{@secret}_#{suffix}.jpg"
  end
end
tags() click to toggle source

flickr.photos.getInfo

# File lib/net/flickr/photo.rb, line 209
def tags
  raise NotImplementedError
end
taken() click to toggle source

Gets the time this photo was taken.

# File lib/net/flickr/photo.rb, line 214
def taken
  info_xml = get_info
  return Time.parse(info_xml.at('dates')[:taken])
end
taken=(time) click to toggle source

flickr.photos.setDates

# File lib/net/flickr/photo.rb, line 220
def taken=(time)
  raise NotImplementedError
end
tiff() click to toggle source

flickr.photos.getExif

# File lib/net/flickr/photo.rb, line 225
def tiff
  raise NotImplementedError
end
title() click to toggle source

Gets this photo's title.

# File lib/net/flickr/photo.rb, line 230
def title
  @title
end
title=(value) click to toggle source

Sets this photo's title. This method requires authentication with write permission.

# File lib/net/flickr/photo.rb, line 236
def title=(value)
  set_meta(value, description)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.