Class: Movescount::Member
- Inherits:
-
Object
- Object
- Movescount::Member
- Includes:
- ActiveModel::Serialization, HTTParty
- Defined in:
- lib/movescount/member.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
debug_output $stderr.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Member
constructor
A new instance of Member.
-
#move_by_id(id) ⇒ Object
Get a move by move_id.
-
#moves(options = {}, force = false) ⇒ Object
Returns the user’s moves Options include: startDate, endDate and maxcount Force argument forces reload of data from api.
-
#profile(force = false) ⇒ Object
Returns the entire user profile Force argument forces reload of data from api.
-
#username ⇒ Object
Returns the user’s movescount username.
Constructor Details
#initialize(options = {}) ⇒ Member
Returns a new instance of Member.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/movescount/member.rb', line 11 def initialize(={}) raise ArgumentError, 'An email is required as an option' unless [:email] raise ArgumentError, 'A userkey is required as an option' unless [:userkey] self.class.base_uri Movescount.configuration.api_uri @options = { query: { appKey: Movescount.configuration.app_key, userKey: .delete(:userkey), email: .delete(:email) } }.merge end |
Instance Attribute Details
#options ⇒ Object (readonly)
debug_output $stderr
9 10 11 |
# File 'lib/movescount/member.rb', line 9 def @options end |
Instance Method Details
#move_by_id(id) ⇒ Object
Get a move by move_id
48 49 50 |
# File 'lib/movescount/member.rb', line 48 def move_by_id(id) Move.new self, self.class.get("/moves/#{id}", @options) end |
#moves(options = {}, force = false) ⇒ Object
Returns the user’s moves Options include: startDate, endDate and maxcount Force argument forces reload of data from api
38 39 40 41 42 43 44 45 |
# File 'lib/movescount/member.rb', line 38 def moves( = {}, force = false) # Return moves if present and not forcing reload return @moves if @moves && !force # Get moves from the api and create move objects @moves = get_moves().map do |move| Move.new self, move end end |
#profile(force = false) ⇒ Object
Returns the entire user profile Force argument forces reload of data from api
26 27 28 |
# File 'lib/movescount/member.rb', line 26 def profile(force = false) force ? @profile = get_profile : @profile ||= get_profile end |
#username ⇒ Object
Returns the user’s movescount username
31 32 33 |
# File 'lib/movescount/member.rb', line 31 def username profile['Username'] end |