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.



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

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

Instance Attribute Details

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#pageObject

Returns the value of attribute page.



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

def page
  @page
end

#pagesObject

Returns the value of attribute pages.



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

def pages
  @pages
end

#perpageObject

Returns the value of attribute perpage.



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

def perpage
  @perpage
end

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

#totalObject

Returns the value of attribute total.



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

def total
  @total
end

Class Method Details

.from_xml(xml, flickr = nil) ⇒ Object



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

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



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

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

#fetch(extras = nil) ⇒ Object



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

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