Sha256: e1c9a681e8195df79058221c70acfc437ff082b0af9f9b94df071b9fe8830603

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 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
    
  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)
    # comment by : smeevil
    #
    # for some reason it was needed to call to_s on photoset.title and photoset.description
    # without this it will not set the value correctly
    {
      :id          => photoset[:id], 
      :num_photos  => photoset[:photos],
      :primary     => photoset[:primary],
      :secret      => photoset[:secret],
      :farm        => photoset[:farm],
      :server      => photoset[:server],
      :title       => photoset.title.to_s,
      :description => photoset.description.to_s,
      :owner       => photoset[:owner]
     }
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

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