Sha256: c524a3114557e6cfd0da3c16abca7a77387e7cd25c53fdf4f20ab6e3b685c92e

Contents?: true

Size: 1.26 KB

Versions: 4

Compression:

Stored size: 1.26 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

  #required:
  # title
  # primary_photo_id
  #
  def create(title, primary_photo_id, options={})
    options.merge!({:title => title, :primary_photo_id => primary_photo_id})
    @flickr.send_request('flickr.photosets.create', options)
  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],
        :title => photoset.title.text.to_s,
        :description => photoset.at_xpath("description").text
       }
    end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fotonauts-flickr_fu-0.3.13 lib/flickr/photosets.rb
fotonauts-flickr_fu-0.3.11 lib/flickr/photosets.rb
fotonauts-flickr_fu-0.3.10 lib/flickr/photosets.rb
fotonauts-flickr_fu-0.3.9 lib/flickr/photosets.rb