Sha256: b9ee90d0c85305ade3d90460be0cc790fad130bb8df80a1d4ad469cb5856b024

Contents?: true

Size: 813 Bytes

Versions: 4

Compression:

Stored size: 813 Bytes

Contents

module Shorty
  # The twurl.nl API class. API documentation: http://tweetburner.com/api
  class Twurl
    attr_reader :options
    include HTTParty
    
    # Standard Error Class
    class Error < StandardError; end
    
    API_URL = 'http://tweetburner.com'
    base_uri API_URL
    
    # shorten. pass:
    # - url: the url to be shortened
    # So to use:
    #   twurl = Shorty::Truwl.new
    #   twurl.shorten('http://google.com')
    def shorten(url)
      query = { :'link[url]' => url }
      self.class.post("/links", :query => query)
    end
    
    # Same as the shorten method, you can just call the following instead:
    #
    #    Shorty::Truwl.shorten('http://google.com')
    def self.shorten(url)
      query = { :'link[url]' => url }
      post("/links", :query => query)
    end

  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
drcapulet-shorty-0.1.0 lib/shorty/twurl.rb
drcapulet-shorty-0.1.1 lib/shorty/twurl.rb
shorty-0.1.2 lib/shorty/twurl.rb
shorty-0.1.1 lib/shorty/twurl.rb