Class: TheCount::Google::Buzz

Inherits:
Countable show all
Defined in:
lib/thecount/countable/google.rb

Instance Attribute Summary

Attributes inherited from Countable

#service_name, #unit, #value

Instance Method Summary collapse

Constructor Details

#initializeBuzz

Returns a new instance of Buzz.



10
11
12
13
14
# File 'lib/thecount/countable/google.rb', line 10

def initialize
  @service_name = "google"
  @unit = "buzz"
  @value = 0
end

Instance Method Details

#count(data) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/thecount/countable/google.rb', line 15

def count(data)
  url = "http://www.google.com/buzz/api/buzzThis/buzzCounter?url="
  url = "#{url}#{CGI::escape(data[:url])}"
  begin
    @value = JSON.parse(open(url).string.split('(')[1].split(')')[0])[data[:url]].to_i
  rescue Exception => e
    @value = 0
  end
end