Class: Google::Expander

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(short_url = "") ⇒ Expander

Returns a new instance of Expander.



52
53
54
55
56
57
58
59
60
61
# File 'lib/google_url_shortner.rb', line 52

def initialize( short_url="" )
  return nil if !short_url.blank?
  rep = Request.get("/urlshortener/v1/url?shortUrl=#{short_url}")
  if rep.code == 200
    self.long_url  = rep['longUrl']
    self.short_url = short_url
  else
    rep.response
  end
end

Instance Attribute Details

#long_urlObject

Returns the value of attribute long_url.



51
52
53
# File 'lib/google_url_shortner.rb', line 51

def long_url
  @long_url
end

#short_urlObject

Returns the value of attribute short_url.



51
52
53
# File 'lib/google_url_shortner.rb', line 51

def short_url
  @short_url
end