Class: Pastebinrb::Pastebin
- Inherits:
-
Object
- Object
- Pastebinrb::Pastebin
- Defined in:
- lib/pastebinrb.rb
Constant Summary collapse
- BASE_URL =
"https://pastebin.com"
Instance Attribute Summary collapse
-
#devkey ⇒ Object
readonly
Returns the value of attribute devkey.
Instance Method Summary collapse
- #get_raw(link) ⇒ Object
-
#initialize(devkey) ⇒ Pastebin
constructor
A new instance of Pastebin.
- #paste_content(content, **options) ⇒ Object
Constructor Details
#initialize(devkey) ⇒ Pastebin
Returns a new instance of Pastebin.
11 12 13 |
# File 'lib/pastebinrb.rb', line 11 def initialize( devkey ) @devkey = devkey end |
Instance Attribute Details
#devkey ⇒ Object (readonly)
Returns the value of attribute devkey.
9 10 11 |
# File 'lib/pastebinrb.rb', line 9 def devkey @devkey end |
Instance Method Details
#get_raw(link) ⇒ Object
27 28 29 |
# File 'lib/pastebinrb.rb', line 27 def get_raw(link) Net::HTTP.get_response(URI.parse("#{BASE_URL}/raw/#{link[/[\w]+$/]}")).body end |
#paste_content(content, **options) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/pastebinrb.rb', line 15 def paste_content( content, ** ) params = { :api_dev_key => @devkey, :api_option => "paste", :api_paste_name => [:title], :api_paste_format => [:format], :api_paste_expire_date => [:expire_delay], :api_paste_code => content } Net::HTTP.post_form(URI.parse("#{BASE_URL}/api/api_post.php"), params).body end |