Sha256: a3064a480cd48c2cefc7498b0faa7f7cdae84045a49fc1ceb9f115f12ad28a28

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

module Rubyoverflow
  class Revisions < PagedBase
    attr_reader :revisions
  
    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
    
    #Retrieves the next set of revisions using the same parameters used to retrieve the current set
    def get_next_set
      hash,url = perform_next_page_request
      Revisions.new hash,url
    end
  
    class << self
    
      #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}'
      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
    
      #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}'
      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
    
    end
  
  end

  class RevisionsDash < PagedDash
    property :revisions
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubyoverflow-1.0.2 lib/rubyoverflow/revisions.rb