Sha256: bbdd74559764aca040d0f7935f671a10e40422777064231a7ec888b2079ed396

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

class Flickr::Photosets::Photoset
  attr_accessor :id, :num_photos, :primary, :secret, :farm, :server, :title, :description, :owner

  def initialize(flickr, attributes)
    @flickr = flickr
    attributes.each do |k,v|
      send("#{k}=", v)
    end
  end

  def get_photos(options={})
    options = options.merge(:photoset_id=>id)
    rsp = @flickr.send_request('flickr.photosets.getPhotos', options)
    collect_photos(rsp)
  end

  def primary_photo_url
    "http://farm#{farm}.static.flickr.com/#{server}/#{primary}_#{secret}_s.jpg"
  end

  protected

  def collect_photos(rsp)
    photos = []
    return photos unless rsp
    if rsp.photoset.photo
      rsp.photoset.photo.each do |photo|
        attributes = create_attributes(photo)
        photos << Flickr::Photos::Photo.new(@flickr,attributes)
      end
    end
    return photos
  end

  def create_attributes(photo)
    {
      :id     => photo[:id],
      :secret => photo[:secret],
      :server => photo[:server],
      :farm   => photo[:farm],
      :title  => photo[:title],
      :url_l  => photo[:url_l],
      :owner  => self.owner
    }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ayn-flickr_fu-0.3.9 lib/flickr/photoset.rb