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.



696
697
698
699
# File 'lib/flickr/base.rb', line 696

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

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



693
694
695
# File 'lib/flickr/base.rb', line 693

def description
  @description
end

#idObject

Returns the value of attribute id.



693
694
695
# File 'lib/flickr/base.rb', line 693

def id
  @id
end

#ownerObject

Returns the value of attribute owner.



693
694
695
# File 'lib/flickr/base.rb', line 693

def owner
  @owner
end

#photo_countObject

Returns the value of attribute photo_count.



693
694
695
# File 'lib/flickr/base.rb', line 693

def photo_count
  @photo_count
end

#primary_idObject

Returns the value of attribute primary_id.



693
694
695
# File 'lib/flickr/base.rb', line 693

def primary_id
  @primary_id
end

#secretObject

Returns the value of attribute secret.



693
694
695
# File 'lib/flickr/base.rb', line 693

def secret
  @secret
end

#serverObject

Returns the value of attribute server.



693
694
695
# File 'lib/flickr/base.rb', line 693

def server
  @server
end

#titleObject

Returns the value of attribute title.



693
694
695
# File 'lib/flickr/base.rb', line 693

def title
  @title
end

#urlObject

Returns the value of attribute url.



693
694
695
# File 'lib/flickr/base.rb', line 693

def url
  @url
end

Class Method Details

.from_xml(xml, flickr = nil) ⇒ Object



715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
# File 'lib/flickr/base.rb', line 715

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



701
702
703
704
# File 'lib/flickr/base.rb', line 701

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

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



706
707
708
709
710
711
# File 'lib/flickr/base.rb', line 706

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

#primaryObject



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

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