Module: Pixy

Defined in:
lib/pixy.rb,
lib/pixy/errors.rb,
lib/pixy/shorten.rb,
lib/pixy/version.rb

Defined Under Namespace

Classes: ApiLimit, EmptyApiKey, EmptyLongUrl, Error, InvalidApiKey, InvalidLongUrl, MissingApiKey, Shorten, UnknownError

Constant Summary collapse

VERSION =
"0.1.2"

Class Method Summary collapse

Class Method Details

.shorten(key = nil, url = '') ⇒ Object

Raises:


8
9
10
11
# File 'lib/pixy.rb', line 8

def self.shorten(key=nil, url='')
  raise MissingApiKey, "API key is required" if key.nil?
  Shorten.new(key, url)
end

.shorten!(key = nil, url = '') ⇒ Object


13
14
15
# File 'lib/pixy.rb', line 13

def self.shorten!(key=nil, url='')
  shorten(key, url).short_url
end

.stats(key = nil, url = '^') ⇒ Object


17
18
19
20
# File 'lib/pixy.rb', line 17

def self.stats(key=nil, url='^')
  pixy = shorten(key, url) # submit fake url to get API rate limit
  { :calls => pixy.counter, :limit => 1000 - pixy.counter }
end