class Dljbz::Shorten
Attributes
long_url[RW]
short_url[RW]
Public Class Methods
new(long_url)
click to toggle source
Creates a new short URL, see Dljbz.shorten
# File lib/dljbz/shorten.rb, line 11 def initialize(long_url) modify_headers('Content-Type' => 'application/json') options = {"long_url" => long_url} resp = post(API_URL, :body => options) if resp.code == 200 or resp.code == 201 self.short_url = resp['short_url'] self.long_url = resp['long_url'] else raise exception(resp.parsed_response) end end