Class: Ribbit
Overview
require “mash”
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #expand(short_url) ⇒ Object
- #info(short_url) ⇒ Object
-
#initialize(username, api_key) ⇒ Ribbit
constructor
A new instance of Ribbit.
- #shorten(long_url) ⇒ Object
- #stats(short_url) ⇒ Object
Constructor Details
#initialize(username, api_key) ⇒ Ribbit
Returns a new instance of Ribbit.
12 13 14 15 16 |
# File 'lib/ribbit.rb', line 12 def initialize(username, api_key) @username = username @api_key = api_key self.class.default_params :version => "2.0.1", :login => @username, :apiKey => @api_key end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
7 8 9 |
# File 'lib/ribbit.rb', line 7 def api_key @api_key end |
#username ⇒ Object
Returns the value of attribute username.
7 8 9 |
# File 'lib/ribbit.rb', line 7 def username @username end |
Instance Method Details
#expand(short_url) ⇒ Object
22 23 24 25 |
# File 'lib/ribbit.rb', line 22 def (short_url) = short_url =~ /^http:\/\// ? {:shortUrl => short_url} : {:hash => short_url} self.class.get("/expand", :query => ) end |
#info(short_url) ⇒ Object
27 28 29 30 |
# File 'lib/ribbit.rb', line 27 def info(short_url) = short_url =~ /^http:\/\// ? {:shortUrl => short_url} : {:hash => short_url} self.class.get("/info", :query => ) end |
#shorten(long_url) ⇒ Object
18 19 20 |
# File 'lib/ribbit.rb', line 18 def shorten(long_url) self.class.get("/shorten", :query => {:longUrl => long_url}) end |
#stats(short_url) ⇒ Object
32 33 34 35 |
# File 'lib/ribbit.rb', line 32 def stats(short_url) = short_url =~ /^http:\/\// ? {:shortUrl => short_url} : {:hash => short_url} self.class.get("/stats", :query => ) end |