Class: Flickr::PhotoPool

Inherits:
Array
  • Object
show all
Defined in:
lib/flickr/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, flickr) ⇒ PhotoPool

Returns a new instance of PhotoPool.



753
754
755
756
# File 'lib/flickr/base.rb', line 753

def initialize(id,flickr)
	@id = id
	@flickr = flickr
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



751
752
753
# File 'lib/flickr/base.rb', line 751

def id
  @id
end

#pageObject

Returns the value of attribute page.



751
752
753
# File 'lib/flickr/base.rb', line 751

def page
  @page
end

#pagesObject

Returns the value of attribute pages.



751
752
753
# File 'lib/flickr/base.rb', line 751

def pages
  @pages
end

#perpageObject

Returns the value of attribute perpage.



751
752
753
# File 'lib/flickr/base.rb', line 751

def perpage
  @perpage
end

#titleObject

Returns the value of attribute title.



751
752
753
# File 'lib/flickr/base.rb', line 751

def title
  @title
end

#totalObject

Returns the value of attribute total.



751
752
753
# File 'lib/flickr/base.rb', line 751

def total
  @total
end

Class Method Details

.from_xml(xml, flickr = nil) ⇒ Object



770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
# File 'lib/flickr/base.rb', line 770

def self.from_xml(xml,flickr=nil)
	att = xml.attributes
	ppid = att['id']

	pool = flickr.photopool_cache_lookup(ppid)
	pool ||= Flickr::PhotoPool.new(ppid,flickr)

	pool.page = att['page'].to_i if att['page']
	pool.pages = att['pages'].to_i if att['pages']
	pool.perpage = att['perpage'].to_i if att['perpage']
	pool.total = att['total'].to_i if att['total']
	if xml.elements['photo']
# I'd like to clear the pool, but I can't because I don't know if I'm
# parsing the full set or just a single "page".
#			pool.clear
		xml.elements.each('photo') do |el|
			pool.<<(Flickr::Photo.from_xml(el,flickr),true)
		end
	end

	flickr.photopool_cache_store(pool) if flickr
	return pool
end

Instance Method Details

#<<(photo, raw = false) ⇒ Object



758
759
760
761
# File 'lib/flickr/base.rb', line 758

def <<(photo,raw=false)
	raw ? super(photo) : @flickr.photosets.addPhoto(self,photo)
	return self
end

#fetch(extras = nil) ⇒ Object



763
764
765
766
767
768
# File 'lib/flickr/base.rb', line 763

def fetch(extras=nil)
	return self if @fetched
	pool = @flickr.groups.pools.getPhotos(self,nil,extras,500)
	@fetched = true
	return pool
end