Class: ShareCount::Reddit
Constant Summary collapse
- URL =
'http://www.reddit.com/api/info.json'
Constants inherited from Base
Base::DEFAULT_OPEN_TIMEOUT, Base::DEFAULT_TIMEOUT
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Methods included from StringHelper
#to_camel_case, #to_underscore
Constructor Details
This class inherits a constructor from ShareCount::Base
Instance Method Details
#shares! ⇒ Object
5 6 7 8 9 10 |
# File 'lib/share_count/reddit.rb', line 5 def shares! response = get(URL, params: { url: checked_url }) children_data = JSON.parse(response)['data']['children'] children_data.map { |c| c['data']['score'] }.reduce(:+) || 0 end |