Class: Flickr::Pools

Inherits:
APIBase show all
Defined in:
lib/flickr/pools.rb

Instance Attribute Summary

Attributes inherited from APIBase

#flickr

Instance Method Summary collapse

Constructor Details

#initialize(flickr, groups) ⇒ Pools

Returns a new instance of Pools.



4
5
6
7
# File 'lib/flickr/pools.rb', line 4

def initialize(flickr,groups)
	super(flickr)
	@groups = groups
end

Instance Method Details

#add(photo, group) ⇒ Object

photo can be a Photo or photo_id group can be a Group or group_id



11
12
13
14
15
16
# File 'lib/flickr/pools.rb', line 11

def add(photo,group)
	group = group.nsid if group.class == Flickr::Group
	photo = photo.id if photo.class == Flickr::Photo
	@flickr.call_method('flickr.groups.pools.add',
		'group_id' => group, 'photo_id' => photo)
end

#getContext(photo, group) ⇒ Object

photo can be a Photo or photo_id group can be a Group or group_id



29
30
31
32
33
34
35
# File 'lib/flickr/pools.rb', line 29

def getContext(photo,group)
	group = group.nsid if group.class == Flickr::Group
	photo = photo.id if photo.class == Flickr::Photo
	res = @flickr.call_method('flickr.groups.pools.getContex',
		'group_id' => group, 'photo_id' => photo)
	return Flickr::Context.from_xml(res)
end

#getGroupsObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/flickr/pools.rb', line 37

def getGroups
	res = @flickr.call_method('flickr.groups.pools.getGroups')
	list = []
	res.elements['/groups'].each_element do |el|
		att = el.attributes
		nsid = att['nsid']
		g = @flickr.group_cache_lookup(nsid) ||
			Flickr::Group.new(@flickr,nsid,att['name'])
		g.name = att['name']
		g.admin = att['admin'].to_i == 1
		g.privacy = Flickr::Group::PRIVACY[att['privacy'].to_i]
		g.photo_count = att['photos'].to_i
		g.iconserver = att['iconserver'].to_i

		@flickr.group_cache_store(g)
		list << g
	end
	return list
end

#getPhotos(group, tags = nil, extras = nil, per_page = nil, page = nil) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/flickr/pools.rb', line 57

def getPhotos(group,tags=nil,extras=nil,per_page=nil,page=nil)
	group = group.nsid if group.class == Flickr::Group
	group = group.id.to_s if group.class == Flickr::PhotoPool
	args = { 'group_id' => group }
	args['tags'] = tags.map{|t| t.clean if t.class ==
		Flick::Tag}.join(',') if tags
	args['extras'] = extras.join(',') if extras.class == Array
	args['per_page'] = per_page if per_page
	args['page'] = page if page

	res = @flickr.call_method('flickr.groups.pools.getPhotos', args)
	return Flickr::PhotoList.from_xml(res,@flickr)
end

#remove(photo, group) ⇒ Object

photo can be a Photo or photo_id group can be a Group or group_id



20
21
22
23
24
25
# File 'lib/flickr/pools.rb', line 20

def remove(photo,group)
	group = group.nsid if group.class == Flickr::Group
	photo = photo.id if photo.class == Flickr::Photo
	@flickr.call_method('flickr.groups.pools.add',
		'group_id' => group, 'photo_id' => photo)
end