Class: Rubyoverflow::Revisions

Inherits:
PagedBase show all
Defined in:
lib/rubyoverflow/revisions.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 = '') ⇒ Revisions

Returns a new instance of Revisions.



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

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

  @revisions = Array.new
  dash.revisions.each{|revisionHash| @revisions.push(Revision.new revisionHash)}
end

Instance Attribute Details

#revisionsObject (readonly)

Returns the value of attribute revisions.



3
4
5
# File 'lib/rubyoverflow/revisions.rb', line 3

def revisions
  @revisions
end

Class Method Details

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

Retrieves the post history of a set of post(s) by their id(s)

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

Maps to ‘revisions/id’



26
27
28
29
30
# File 'lib/rubyoverflow/revisions.rb', line 26

def retrieve_by_post(id, parameters = {})
  id = convert_to_id_list(id)
  hash, url = request('/revisions/'+id.to_s, parameters)
  Revisions.new hash, url
end

.retrieve_post_revision(id, revisionguid, parameters = {}) ⇒ Object

Retrieves a specific post revision by post id and revision guid

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

revisionguid must be a string in 8-4-4-4-12 format

Maps to ‘revisions/id’



39
40
41
42
43
# File 'lib/rubyoverflow/revisions.rb', line 39

def retrieve_post_revision(id, revisionguid, parameters = {})
  id = convert_to_id_list(id)
  hash, url = request('/revisions/'+id.to_s + '/' + revisionguid, parameters)
  Revisions.new hash, url
end

Instance Method Details

#get_next_setObject

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



14
15
16
17
# File 'lib/rubyoverflow/revisions.rb', line 14

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