Class: Skore::PeerIndex
- Inherits:
-
Object
- Object
- Skore::PeerIndex
- Includes:
- HTTParty
- Defined in:
- lib/skore/peerindex.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(api_key) ⇒ PeerIndex
constructor
Initialize and load data from kred api.
-
#score(username) ⇒ Object
Get core from peerindex api.
Constructor Details
#initialize(api_key) ⇒ PeerIndex
Initialize and load data from kred api
15 16 17 18 |
# File 'lib/skore/peerindex.rb', line 15 def initialize(api_key) raise ArgumentError, 'api_key is required' if api_key == nil || api_key.empty? @api_key = api_key end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
12 13 14 |
# File 'lib/skore/peerindex.rb', line 12 def data @data end |
Instance Method Details
#score(username) ⇒ Object
Get core from peerindex api
21 22 23 24 25 26 27 28 29 |
# File 'lib/skore/peerindex.rb', line 21 def score(username) begin @data = self.class.get("?twitter_screen_name=#{username}&api_key=#{@api_key}", verify: false) result = @data ? JSON.parse(@data.body) : nil result['peerindex'] if result rescue Timeout::Error nil end end |