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.



770
771
772
773
# File 'lib/flickr/base.rb', line 770

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

Instance Attribute Details

#idObject

Returns the value of attribute id.



768
769
770
# File 'lib/flickr/base.rb', line 768

def id
  @id
end

#pageObject

Returns the value of attribute page.



768
769
770
# File 'lib/flickr/base.rb', line 768

def page
  @page
end

#pagesObject

Returns the value of attribute pages.



768
769
770
# File 'lib/flickr/base.rb', line 768

def pages
  @pages
end

#perpageObject

Returns the value of attribute perpage.



768
769
770
# File 'lib/flickr/base.rb', line 768

def perpage
  @perpage
end

#titleObject

Returns the value of attribute title.



768
769
770
# File 'lib/flickr/base.rb', line 768

def title
  @title
end

#totalObject

Returns the value of attribute total.



768
769
770
# File 'lib/flickr/base.rb', line 768

def total
  @total
end

Class Method Details

.from_xml(xml, flickr = nil) ⇒ Object



787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
# File 'lib/flickr/base.rb', line 787

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



775
776
777
778
# File 'lib/flickr/base.rb', line 775

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

#fetch(extras = nil) ⇒ Object



780
781
782
783
784
785
# File 'lib/flickr/base.rb', line 780

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