Class: Ribbit

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/ribbit.rb

Overview

require “mash”

Instance Attribute Summary collapse

Instance Method Summary collapse

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_keyObject

Returns the value of attribute api_key.



7
8
9
# File 'lib/ribbit.rb', line 7

def api_key
  @api_key
end

#usernameObject

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 expand(short_url)
	options = short_url =~ /^http:\/\// ? {:shortUrl => short_url} : {:hash => short_url}
	self.class.get("/expand", :query => options)
end

#info(short_url) ⇒ Object



27
28
29
30
# File 'lib/ribbit.rb', line 27

def info(short_url)
	options = short_url =~ /^http:\/\// ? {:shortUrl => short_url} : {:hash => short_url}
	self.class.get("/info", :query => options)
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)
	options = short_url =~ /^http:\/\// ? {:shortUrl => short_url} : {:hash => short_url}
	self.class.get("/stats", :query => options)
end