Class: Dljbz::Shorten
Constant Summary
Constants included from Utils
Instance Attribute Summary collapse
-
#long_url ⇒ Object
Returns the value of attribute long_url.
-
#short_url ⇒ Object
Returns the value of attribute short_url.
Instance Method Summary collapse
-
#initialize(long_url) ⇒ Shorten
constructor
Creates a new short URL, see Dljbz.shorten.
Methods inherited from Base
Constructor Details
#initialize(long_url) ⇒ Shorten
Creates a new short URL, see Dljbz.shorten
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/dljbz/shorten.rb', line 11 def initialize(long_url) modify_headers('Content-Type' => 'application/json') = {"long_url" => long_url}.to_json resp = post(API_URL, :body => ) 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 |
Instance Attribute Details
#long_url ⇒ Object
Returns the value of attribute long_url.
7 8 9 |
# File 'lib/dljbz/shorten.rb', line 7 def long_url @long_url end |
#short_url ⇒ Object
Returns the value of attribute short_url.
7 8 9 |
# File 'lib/dljbz/shorten.rb', line 7 def short_url @short_url end |