Class: Flickr::Tags

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

Instance Attribute Summary

Attributes inherited from APIBase

#flickr

Instance Method Summary collapse

Methods inherited from APIBase

#initialize

Constructor Details

This class inherits a constructor from Flickr::APIBase

Instance Method Details

#getListPhoto(photo) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/flickr/tags.rb', line 24

def getListPhoto(photo)
	photo = photo.id if photo.class == Flickr::Photo
	res = @flickr.call_method('flickr.tags.getListPhoto',
		'photo_id'=>photo)
	xml = res.root
	phid = xml.attributes['id']
	photo = (photo.class == Flickr::Photo) ? photo :
	  (@flickr.photo_cache_lookup(phid) ||
		  Flickr::Photo.new(@flickr,phid))
	if xml.elements['tags']
		tags = []
		xml.elements['tags'].each_element do |el|
			tags << Flickr::Tag.from_xml(el,photo)
		end
	end
	photo.tags = tags
	return tags
end

#getListUser(user) ⇒ Object



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

def getListUser(user)
	user = user.nsid if user.class == Flickr::Person
	args = { 'user_id' => user }

	res = @flickr.call_method('flickr.tags.getListUser',args)
	tags = []
	res.elements['/who/tags'].each_element do |tag|
		tags << tag.text
	end
	return tags
end

#getListUserPopular(user, count = nil) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/flickr/tags.rb', line 43

def getListUserPopular(user,count = nil)
	user = user.nsid if user.class == Flickr::Person
	args = { 'user_id' => user }
	args['count'] = count if count

	res = @flickr.call_method('flickr.tags.getListUserPopular',args)
	tags = {}
	res.elements['/who/tags'].each_element do |tag|
		att = tag.attributes
		tags[tag.text]=att['count'].to_i
	end
	return tags
end

#getRelated(tag) ⇒ Object



69
70
71
72
73
74
75
76
77
78
# File 'lib/flickr/tags.rb', line 69

def getRelated(tag)
	args = { 'tag' => tag }

	res = @flickr.call_method('flickr.tags.getRelated',args)
	tags = []
	res.elements['/tags'].each_element do |tag|
		tags << tag.text
	end
	return tags
end