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



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/flickr/tags.rb', line 4

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



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/flickr/tags.rb', line 37

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



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/flickr/tags.rb', line 23

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



49
50
51
52
53
54
55
56
57
58
# File 'lib/flickr/tags.rb', line 49

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