Class: Flickr::Comments

Inherits:
APIBase show all
Defined in:
lib/flickr/comments.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

#add(photo, comment) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/flickr/comments.rb', line 5

def add(photo, comment)
	photo = photo.id if photo.class == Flickr::Photo
	res = @flickr.call_method('flickr.photos.comments.addComment',
		'photo_id' => photo, 'comment_text' => comment)
	xml = res.root
	xml.attributes['id']
end

#delete(comment_id) ⇒ Object



13
14
15
16
# File 'lib/flickr/comments.rb', line 13

def delete(comment_id)
	@flickr.call_method('flickr.photos.comments.deleteComment',
		'comment_id' => comment_id)
end

#edit(comment_id, comment) ⇒ Object



18
19
20
21
# File 'lib/flickr/comments.rb', line 18

def edit(comment_id, comment)
	@flickr.call_method('flickr.photos.comments.editComment',
		'comment_id' => comment_id, 'comment_text' => comment)
end

#list(photo) ⇒ Object



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

def list(photo)
	photo = photo.id if photo.class == Flickr::Photo
	res = @flickr.call_method('flickr.photos.comments.getList',
		'photo_id' => photo)
	rv = []
	res.elements['//comments'].each_element do |e|
		rv << Flickr::Comment.from_xml(e, @flickr)
	end
	rv
end