class Gratitude::Profile

Attributes

username[R]

Public Class Methods

new(username) click to toggle source
# File lib/gratitude/profile.rb, line 8
def initialize(username)
  @username = username
end

Public Instance Methods

amount_giving()
Alias for: giving
amount_receiving() click to toggle source
# File lib/gratitude/profile.rb, line 32
def amount_receiving
  response_body.fetch("receiving").to_f
end
Also aliased as: receiving
bitcoin() click to toggle source
# File lib/gratitude/profile.rb, line 41
def bitcoin
  response_body.fetch("bitcoin") { nil }
end
giving() click to toggle source
# File lib/gratitude/profile.rb, line 27
def giving
  response_body.fetch("giving").to_f
end
Also aliased as: amount_giving
goal() click to toggle source
# File lib/gratitude/profile.rb, line 37
def goal
  response_body.fetch("goal").to_f if response_body["goal"]
end
receiving()
Alias for: amount_receiving

Private Instance Methods

response() click to toggle source
# File lib/gratitude/profile.rb, line 64
def response
  @response ||= faraday.get("/#{username}/public.json")
  raise UsernameNotFoundError, username if @response.status == 406
  @response
end
response_body() click to toggle source
# File lib/gratitude/profile.rb, line 70
def response_body
  @response_body ||= response.body
end