Class: Flickr::PhotoSet

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) ⇒ PhotoSet

Returns a new instance of PhotoSet.



713
714
715
716
# File 'lib/flickr/base.rb', line 713

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

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



710
711
712
# File 'lib/flickr/base.rb', line 710

def description
  @description
end

#idObject

Returns the value of attribute id.



710
711
712
# File 'lib/flickr/base.rb', line 710

def id
  @id
end

#ownerObject

Returns the value of attribute owner.



710
711
712
# File 'lib/flickr/base.rb', line 710

def owner
  @owner
end

#photo_countObject

Returns the value of attribute photo_count.



710
711
712
# File 'lib/flickr/base.rb', line 710

def photo_count
  @photo_count
end

#primary_idObject

Returns the value of attribute primary_id.



710
711
712
# File 'lib/flickr/base.rb', line 710

def primary_id
  @primary_id
end

#secretObject

Returns the value of attribute secret.



710
711
712
# File 'lib/flickr/base.rb', line 710

def secret
  @secret
end

#serverObject

Returns the value of attribute server.



710
711
712
# File 'lib/flickr/base.rb', line 710

def server
  @server
end

#titleObject

Returns the value of attribute title.



710
711
712
# File 'lib/flickr/base.rb', line 710

def title
  @title
end

#urlObject

Returns the value of attribute url.



710
711
712
# File 'lib/flickr/base.rb', line 710

def url
  @url
end

Class Method Details

.from_xml(xml, flickr = nil) ⇒ Object



732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
# File 'lib/flickr/base.rb', line 732

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

	set = flickr.photoset_cache_lookup(psid) if flickr
	set ||= Flickr::PhotoSet.new(psid,flickr)

	set.secret = att['secret']
	set.owner = att['owner']
	set.url = att['url']
	set.server = att['server'].to_i
	set.primary_id = att['primary'].to_i
	set.photo_count = att['photos'].to_i
	set.title = xml.elements['title'].text if xml.elements['title']
	set.description = xml.elements['description'].text if
	xml.elements['description']
	if xml.elements['photo']
		set.clear
		xml.elements.each('photo') do |el|
			set.<<(Flickr::Photo.from_xml(el,flickr),true)
		end
	end

	flickr.photoset_cache_store(set) if flickr
	return set
end

Instance Method Details

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



718
719
720
721
# File 'lib/flickr/base.rb', line 718

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

#fetch(extras = nil) ⇒ Object Also known as: photos



723
724
725
726
727
728
# File 'lib/flickr/base.rb', line 723

def fetch(extras=nil)
	return self if @fetched
	set = @flickr.photosets.getPhotos(self,extras)
	@fetched = true
	return set
end

#primaryObject



764
# File 'lib/flickr/base.rb', line 764

def primary() @primary ||= @flickr.photos.getInfo(@primary_id) end