Class: Google::Shortner

Inherits:
Object
  • Object
show all
Defined in:
lib/google_url_shortner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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)
  options = {"longUrl" => long_url}.inspect
  resp = Request.post('/urlshortener/v1/url', :body => options)
  if resp.code == 200            
    self.short_url = resp['id']
    self.long_url  = resp['longUrl']        
  else
    resp.response
  end
end

Instance Attribute Details

#long_urlObject

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_urlObject

Returns the value of attribute short_url.



67
68
69
# File 'lib/google_url_shortner.rb', line 67

def short_url
  @short_url
end