class UrlExpander::Expanders::Googl
Expand Google URLS Usage: UrlExpander::Client.expand
(“goo.gl/DRppM”)
Constants
- PATTERN
NOTICE: We ignored the / before the key goo.gl/DRppM => 'DRppM' without /
Attributes
parent_klass[R]
Public Class Methods
new(short_url, options={})
click to toggle source
Calls superclass method
UrlExpander::Expanders::API::new
# File lib/url_expander/expanders/api/googl.rb, line 16 def initialize(short_url, options={}) @parent_klass = self super(short_url,options) fetch_url end
Private Instance Methods
fetch_url()
click to toggle source
# File lib/url_expander/expanders/api/googl.rb, line 31 def fetch_url response = Request.get("/urlshortener/v1/url?shortUrl=http://goo.gl/#{@shortner_key}") if response.code == 200 @long_url = response['longUrl'] else error = (JSON.parse response.body)['error'] raise UrlExpander::Error.new(error['message'],response.code) end end