Class: Googl::Expand
Constant Summary
Constants included from Utils
Utils::API_CLIENT_LOGIN_URL, Utils::API_HISTORY_URL, Utils::API_URL, Utils::SCOPE_URL
Instance Attribute Summary collapse
-
#analytics ⇒ Object
Returns the value of attribute analytics.
-
#created ⇒ Object
Returns the value of attribute created.
-
#long_url ⇒ Object
Returns the value of attribute long_url.
-
#short_url ⇒ Object
Returns the value of attribute short_url.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Expand
constructor
Expands a short URL or gets creation time and analytics.
Methods inherited from Base
Constructor Details
#initialize(options = {}) ⇒ Expand
Expands a short URL or gets creation time and analytics. See Googl.expand
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/googl/expand.rb', line 11 def initialize(={}) .delete_if {|key, value| value.nil?} resp = get(API_URL, :query => ) 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.}") end end |
Instance Attribute Details
#analytics ⇒ Object
Returns the value of attribute analytics.
7 8 9 |
# File 'lib/googl/expand.rb', line 7 def analytics @analytics end |
#created ⇒ Object
Returns the value of attribute created.
7 8 9 |
# File 'lib/googl/expand.rb', line 7 def created @created end |
#long_url ⇒ Object
Returns the value of attribute long_url.
7 8 9 |
# File 'lib/googl/expand.rb', line 7 def long_url @long_url end |
#short_url ⇒ Object
Returns the value of attribute short_url.
7 8 9 |
# File 'lib/googl/expand.rb', line 7 def short_url @short_url end |
#status ⇒ Object
Returns the value of attribute status.
7 8 9 |
# File 'lib/googl/expand.rb', line 7 def status @status end |