Class: TheCount::Digg
- Defined in:
- lib/thecount/countable/digg.rb
Instance Attribute Summary
Attributes inherited from Countable
Instance Method Summary collapse
- #count(data) ⇒ Object
-
#initialize ⇒ Digg
constructor
A new instance of Digg.
Constructor Details
#initialize ⇒ Digg
Returns a new instance of Digg.
7 8 9 10 11 |
# File 'lib/thecount/countable/digg.rb', line 7 def initialize @service_name = "digg" @unit = "digg" @value = 0 end |
Instance Method Details
#count(data) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/thecount/countable/digg.rb', line 13 def count(data) url = data[:url] begin url = "http://widgets.digg.com/buttons/count?url=#{url}" @value = JSON.parse(open(url).string.split("(")[1].split(");")[0])["diggs"].to_i rescue @value = 0 end end |