Class: Google::UrlShortner::Analytics
- Inherits:
-
Object
- Object
- Google::UrlShortner::Analytics
- Defined in:
- lib/google_url_shortner.rb
Instance Attribute Summary collapse
-
#browsers ⇒ Object
readonly
Returns the value of attribute browsers.
-
#countries ⇒ Object
readonly
Returns the value of attribute countries.
-
#long_url ⇒ Object
readonly
Returns the value of attribute long_url.
-
#platforms ⇒ Object
readonly
Returns the value of attribute platforms.
-
#visitors ⇒ Object
readonly
Returns the value of attribute visitors.
Instance Method Summary collapse
-
#initialize(url = "") ⇒ Analytics
constructor
A new instance of Analytics.
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
#browsers ⇒ Object (readonly)
Returns the value of attribute browsers.
7 8 9 |
# File 'lib/google_url_shortner.rb', line 7 def browsers @browsers end |
#countries ⇒ Object (readonly)
Returns the value of attribute countries.
7 8 9 |
# File 'lib/google_url_shortner.rb', line 7 def countries @countries end |
#long_url ⇒ Object (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 |
#platforms ⇒ Object (readonly)
Returns the value of attribute platforms.
7 8 9 |
# File 'lib/google_url_shortner.rb', line 7 def platforms @platforms end |
#visitors ⇒ Object (readonly)
Returns the value of attribute visitors.
7 8 9 |
# File 'lib/google_url_shortner.rb', line 7 def visitors @visitors end |