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