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.

[View source]

755
756
757
758
# File 'lib/flickr/base.rb', line 755

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

Instance Attribute Details

#idObject

Returns the value of attribute id.


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

def id
  @id
end

#pageObject

Returns the value of attribute page.


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

def page
  @page
end

#pagesObject

Returns the value of attribute pages.


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

def pages
  @pages
end

#perpageObject

Returns the value of attribute perpage.


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

def perpage
  @perpage
end

#titleObject

Returns the value of attribute title.


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

def title
  @title
end

#totalObject

Returns the value of attribute total.


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

def total
  @total
end

Class Method Details

.from_xml(xml, flickr = nil) ⇒ Object

[View source]

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

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

[View source]

760
761
762
763
# File 'lib/flickr/base.rb', line 760

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

#fetch(extras = nil) ⇒ Object

[View source]

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

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