class Refheap::Paste
Public Class Methods
new(username = nil, token = nil)
click to toggle source
Set some default_params based on the username and token (or lack thereof).
# File lib/rubyheap/rubyheap.rb, line 14 def initialize(username = nil, token = nil) if username && token @base_params = {:username => username, :token => token} else @base_params = {} end end
Public Instance Methods
create(contents, params = {:language => "Plain Text", :private => false})
click to toggle source
Create a new paste. If language isn’t provided, it defaults to “Plain Text”. If private isn’t provided, it defaults to false.
# File lib/rubyheap/rubyheap.rb, line 29 def create(contents, params = {:language => "Plain Text", :private => false}) params = params.merge({:contents => contents}.merge(@base_params)) self.class.post("/paste", :body => params).parsed_response end
delete(id)
click to toggle source
Delete a paste.
# File lib/rubyheap/rubyheap.rb, line 35 def delete(id) self.class.delete("/paste/#{id}", :query => @base_params).parsed_response.nil? end
edit(id, params = {})
click to toggle source
Edit a paste. Optional params are any of:
-
:private
-
:language
-
:contents
All of these are optional. If any of them aren’t provided in the edit, they will remain the same.
# File lib/rubyheap/rubyheap.rb, line 45 def edit(id, params = {}) self.class.post("/paste/#{id}", :body => params.merge(@base_params)).parsed_response end
fork(id)
click to toggle source
Fork a paste.
# File lib/rubyheap/rubyheap.rb, line 50 def fork(id) self.class.post("/paste/#{id}/fork", :body => @base_params).parsed_response end
get(id)
click to toggle source
Get a paste from RefHeap by ID.
# File lib/rubyheap/rubyheap.rb, line 23 def get(id) self.class.get("/paste/#{id}").parsed_response end