class Googl::Expand
Attributes
analytics[RW]
created[RW]
long_url[RW]
short_url[RW]
status[RW]
Public Class Methods
new(options={})
click to toggle source
Expands a short URL or gets creation time and analytics. See Googl.expand
# File lib/googl/expand.rb, line 11 def initialize(options={}) options.delete_if {|key, value| value.nil?} resp = get(API_URL, :query => options) if resp.code == 200 self.created = resp['created'] if resp.has_key?('created') self.long_url = resp['longUrl'] self.analytics = resp['analytics'].to_openstruct if resp.has_key?('analytics') self.status = resp['status'] self.short_url = resp['id'] else raise exception("#{resp.code} #{resp.message}") end end