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.



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

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

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



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

def description
  @description
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#ownerObject

Returns the value of attribute owner.



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

def owner
  @owner
end

#photo_countObject

Returns the value of attribute photo_count.



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

def photo_count
  @photo_count
end

#primary_idObject

Returns the value of attribute primary_id.



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

def primary_id
  @primary_id
end

#secretObject

Returns the value of attribute secret.



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

def secret
  @secret
end

#serverObject

Returns the value of attribute server.



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

def server
  @server
end

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end

Class Method Details

.from_xml(xml, flickr = nil) ⇒ Object



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
741
# File 'lib/flickr/base.rb', line 716

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



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

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

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



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

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

#primaryObject



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

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