Class: Rubyoverflow::Comments

Inherits:
PagedBase show all
Defined in:
lib/rubyoverflow/comments.rb

Instance Attribute Summary collapse

Attributes inherited from PagedBase

#page, #pagesize, #query_parameters, #request_path, #total

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PagedBase

#next_page_parameters, #perform_next_page_request

Methods inherited from Base

change_end_point, client, convert_if_array, convert_to_id_list, #find_parse_querystring, request, #request

Constructor Details

#initialize(hash, request_path = '') ⇒ Comments

Returns a new instance of Comments.



6
7
8
9
10
11
12
13
# File 'lib/rubyoverflow/comments.rb', line 6

def initialize(hash, request_path = '')
  dash = CommentsDash.new hash

  @comments = Array.new
  dash.comments.each{ |commentHash| @comments.push(Comment.new commentHash)}

  super(dash, request_path)
end

Instance Attribute Details

#commentsObject (readonly)

Returns the value of attribute comments.



4
5
6
# File 'lib/rubyoverflow/comments.rb', line 4

def comments
  @comments
end

Class Method Details

.retrieve_by_answer(id, parameters = {}) ⇒ Object

Retrieves a set of comments made on an answer by the answer’s id

id can be an int, string, or an array of ints or strings

Maps to ‘answers/id/comments’



52
53
54
55
56
57
# File 'lib/rubyoverflow/comments.rb', line 52

def retrieve_by_answer(id, parameters={})
  id = convert_to_id_list(id)

  hash, url = request('answers/'+id.to_s+"/comments", parameters)
  Comments.new hash, url
end

.retrieve_by_id(id, parameters = {}) ⇒ Object

Retieves a set of comments by a set by their ids

id can be an int, string, or an array of ints or strings

Maps to ‘comments/id



28
29
30
31
32
33
# File 'lib/rubyoverflow/comments.rb', line 28

def retrieve_by_id(id, parameters = {})
  id = convert_to_id_list(id)

  hash, url = request('comments/'+id.to_s, parameters)
  Comments.new hash, url
end

.retrieve_by_post(id, parameters = {}) ⇒ Object

Retrieves a set of comments made on a post by the post’s id

id can be an int, string, or an array of ints or strings

Maps to ‘posts/id/comments’



64
65
66
67
68
69
# File 'lib/rubyoverflow/comments.rb', line 64

def retrieve_by_post(id, parameters={})
  id = convert_to_id_list(id)

  hash, url = request('posts/'+id.to_s+"/comments", parameters)
  Comments.new hash, url
end

.retrieve_by_question(id, parameters = {}) ⇒ Object

Retrieves a set comments made on a question by the post’s id

id can be an int, string, or an array of ints or strings

Maps to ‘question/id/comments’



76
77
78
79
80
81
# File 'lib/rubyoverflow/comments.rb', line 76

def retrieve_by_question(id, parameters={})
  id = convert_to_id_list(id)

  hash, url = request('questions/'+id.to_s+"/comments", parameters)
  Comments.new hash, url
end

.retrieve_by_user(id, parameters = {}) ⇒ Object

Retrieves a set of comments made by a set of users by their ids

id can be an int, string, or an array of ints or strings

Maps to ‘users/id/comments’



40
41
42
43
44
45
# File 'lib/rubyoverflow/comments.rb', line 40

def retrieve_by_user(id, parameters={})
  id = convert_to_id_list(id)

  hash, url = request('users/'+id.to_s+"/comments", parameters)
  Comments.new hash, url
end

.retrieve_from_user_to_user(id, toid, parameters = {}) ⇒ Object

Retrieves a set of comments made by a set of users to a user

id can be an int, string, or an array of ints or strings

toid must be an int or string

Maps to ‘users/id/comments/toid’



90
91
92
93
94
95
# File 'lib/rubyoverflow/comments.rb', line 90

def retrieve_from_user_to_user(id, toid, parameters={})
  id = convert_to_id_list(id)

  hash, url = request('users/'+id.to_s+"/comments/" + toid.to_s, parameters)
  Comments.new hash, url
end

.retrieve_to_user(id, parameters = {}) ⇒ Object

Retieves a set commments directed at a set of users by their ids

id can be an int, string, or an array of ints or strings

Maps to ‘users/id/mentioned’



102
103
104
105
106
107
# File 'lib/rubyoverflow/comments.rb', line 102

def retrieve_to_user(id, parameters={})
  id = convert_to_id_list(id)

  hash, url = request('users/'+id.to_s+"/mentioned", parameters)
  Comments.new hash, url
end

Instance Method Details

#get_next_setObject

Retrieves the next set of comments using the same parameters used to retrieve the current set



16
17
18
19
# File 'lib/rubyoverflow/comments.rb', line 16

def get_next_set
  hash,url = perform_next_page_request
  Comments.new hash,url
end