Class: Google::Shortner
- Inherits:
-
Object
- Object
- Google::Shortner
- Defined in:
- lib/google_url_shortner.rb
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) ⇒ Shortner
constructor
A new instance of Shortner.
Constructor Details
#initialize(long_url) ⇒ Shortner
Returns a new instance of Shortner.
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/google_url_shortner.rb', line 68 def initialize(long_url) = {"longUrl" => long_url}.inspect resp = Request.post('/urlshortener/v1/url', :body => ) if resp.code == 200 self.short_url = resp['id'] self.long_url = resp['longUrl'] else resp.response end end |
Instance Attribute Details
#long_url ⇒ Object
Returns the value of attribute long_url.
67 68 69 |
# File 'lib/google_url_shortner.rb', line 67 def long_url @long_url end |
#short_url ⇒ Object
Returns the value of attribute short_url.
67 68 69 |
# File 'lib/google_url_shortner.rb', line 67 def short_url @short_url end |