Sha256: 28936269859c4a91ed9d2e17bf895c4ef2c1f77344bdc2fa6020a4734573510a

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

class Flickr::Photosets < Flickr::Base
  def initialize(flickr)
    @flickr = flickr
  end
  
  # Get the authorized user's contact list.
  # 
  def get_list(options={})
    rsp = @flickr.send_request('flickr.photosets.getList', options)
    collect_photosets(rsp)
  end
  
  def get_info(options={})
    return nil unless options[:photoset_id]
    rsp = @flickr.send_request('flickr.photosets.getInfo', options)
    return nil unless rsp
    photoset = nil
    if rsp.photoset
      attributes = create_attributes(rsp.photoset)
      photoset = Photoset.new(@flickr, attributes)
    end
    return photoset
  end
    
  protected  
    def collect_photosets(rsp)
      photosets = []
      return photosets unless rsp
      if rsp.photosets.photoset
        rsp.photosets.photoset.each do |photoset|
          attributes = create_attributes(photoset)
          photosets << Photoset.new(@flickr, attributes)
        end
      end
      return photosets
    end
  
    def create_attributes(photoset)

      {
        :id => photoset[:id], 
        :num_photos => photoset[:photos],
        :secret => photoset[:secret],
        :server => photoset[:server],
        :farm => photoset[:farm],
        :primary => photoset[:primary],
        :title => photoset.title.to_s,
        :description => photoset.description.to_s,
       }
    end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mrpunkin-flickr_fu-0.3.0 lib/flickr/photosets.rb