Class: Google::UrlShortner::Analytics

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url = "") ⇒ Analytics

Returns a new instance of Analytics.



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/google_url_shortner.rb', line 13

def initialize( url="" )        
  return {} if url == ""
  resp           ||= Request.get("/urlshortener/v1/url?shortUrl=#{url}&projection=FULL")
  @analytics     ||= resp['analytics']['allTime'] if resp
  
  @long_url        = url 
  @visitors        = @analytics['shortUrlClicks'].to_i if @analytics
  @browsers        = @analytics['browsers'] if @analytics
  @countries       = @analytics['countries'] if @analytics
  @platforms       = @analytics['platforms'] if @analytics
  [@long_url]
end

Instance Attribute Details

#browsersObject (readonly)

Returns the value of attribute browsers.



7
8
9
# File 'lib/google_url_shortner.rb', line 7

def browsers
  @browsers
end

#countriesObject (readonly)

Returns the value of attribute countries.



7
8
9
# File 'lib/google_url_shortner.rb', line 7

def countries
  @countries
end

#long_urlObject (readonly)

Returns the value of attribute long_url.



7
8
9
# File 'lib/google_url_shortner.rb', line 7

def long_url
  @long_url
end

#platformsObject (readonly)

Returns the value of attribute platforms.



7
8
9
# File 'lib/google_url_shortner.rb', line 7

def platforms
  @platforms
end

#visitorsObject (readonly)

Returns the value of attribute visitors.



7
8
9
# File 'lib/google_url_shortner.rb', line 7

def visitors
  @visitors
end