Class: Whatpulse::Client
- Inherits:
-
Object
- Object
- Whatpulse::Client
- Defined in:
- lib/whatpulse.rb
Constant Summary collapse
- @@baseUserUri =
"http://api.whatpulse.org/user.php"- @@basePulseUri =
"http://api.whatpulse.org/pulses.php"
Instance Attribute Summary collapse
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #getPulses ⇒ Object
- #getUserData ⇒ Object
-
#initialize(user) ⇒ Client
constructor
A new instance of Client.
- #makeCall(fullUrl) ⇒ Object
Constructor Details
#initialize(user) ⇒ Client
Returns a new instance of Client.
14 15 16 |
# File 'lib/whatpulse.rb', line 14 def initialize(user) @user = user end |
Instance Attribute Details
#user ⇒ Object
Returns the value of attribute user.
9 10 11 |
# File 'lib/whatpulse.rb', line 9 def user @user end |
Instance Method Details
#getPulses ⇒ Object
23 24 25 26 |
# File 'lib/whatpulse.rb', line 23 def getPulses apiURL = "#{@@basePulseUri}?user=#{@user}&formatted=yes&format=json" return makeCall(apiURL) end |
#getUserData ⇒ Object
18 19 20 21 |
# File 'lib/whatpulse.rb', line 18 def getUserData apiURL = "#{@@baseUserUri}?user=#{@user}&formatted=yes&format=json" return makeCall(apiURL) end |
#makeCall(fullUrl) ⇒ Object
28 29 30 |
# File 'lib/whatpulse.rb', line 28 def makeCall(fullUrl) return JSON.parse(HTTParty.get(fullUrl, :timeout => 10).body) end |