Class: TriviaCrack::User
- Inherits:
-
Object
- Object
- TriviaCrack::User
- Defined in:
- lib/triviacrack/user.rb
Instance Attribute Summary collapse
-
#coins ⇒ Object
readonly
Public: The amount of coins that the user has accumulated.
-
#country ⇒ Object
readonly
Public: The country code of the user’s country.
-
#extra_shots ⇒ Object
readonly
Public: The number of extra shots available to the user.
-
#facebook_id ⇒ Object
readonly
Public: The Facebook ID of the user (nil if the user has not linked their Facebook account).
-
#facebook_name ⇒ Object
readonly
Public: The Facebook name of the user (nil if the user has not linked their Facebook account).
-
#goal_points ⇒ Object
readonly
Public: The user’s goal points.
-
#id ⇒ Object
readonly
Public: The unique identifier of the user.
-
#level ⇒ Object
readonly
Public: The user’s level.
-
#level_points ⇒ Object
readonly
Public: The experience points that the user has accumulated towards their next level.
-
#level_progress ⇒ Object
readonly
Public: The percentage progress towards the next level.
-
#level_up ⇒ Object
readonly
Public: Boolean indicating whether the user has leveled up.
-
#lives ⇒ Object
readonly
Public: The amount of lives available to the user.
-
#max_lives ⇒ Object
readonly
Public: The maximum number of lives that the user can have.
-
#unlimited_lives ⇒ Object
readonly
Public: Boolean indicating whether the user has unlimited lives.
-
#username ⇒ Object
readonly
Public: The unique username of the user.
Instance Method Summary collapse
-
#initialize(id:, username: nil, facebook_id: nil, facebook_name: nil, coins: nil, lives: nil, max_lives: nil, unlimited_lives: nil, country: nil, extra_shots: nil, level: nil, level_points: nil, level_progress: nil, goal_points: nil, level_up: nil) ⇒ User
constructor
A new instance of User.
-
#start_new_game? ⇒ Boolean
Public: Returns true if the user has one or more lives, or has unlimited lives.
Constructor Details
#initialize(id:, username: nil, facebook_id: nil, facebook_name: nil, coins: nil, lives: nil, max_lives: nil, unlimited_lives: nil, country: nil, extra_shots: nil, level: nil, level_points: nil, level_progress: nil, goal_points: nil, level_up: nil) ⇒ User
Returns a new instance of User.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/triviacrack/user.rb', line 54 def initialize(id:, username: nil, facebook_id: nil, facebook_name: nil, coins: nil, lives: nil, max_lives: nil, unlimited_lives: nil, country: nil, extra_shots: nil, level: nil, level_points: nil, level_progress: nil, goal_points: nil, level_up: nil) @id = id @username = username @facebook_id = facebook_id @facebook_name = facebook_name @coins = coins @lives = lives @max_lives = max_lives @unlimited_lives = unlimited_lives @country = country @extra_shots = extra_shots @level = level @level_points = level_points @level_progress = level_progress @goal_points = goal_points @level_up = level_up end |
Instance Attribute Details
#coins ⇒ Object (readonly)
Public: The amount of coins that the user has accumulated.
21 22 23 |
# File 'lib/triviacrack/user.rb', line 21 def coins @coins end |
#country ⇒ Object (readonly)
Public: The country code of the user’s country.
33 34 35 |
# File 'lib/triviacrack/user.rb', line 33 def country @country end |
#extra_shots ⇒ Object (readonly)
Public: The number of extra shots available to the user.
36 37 38 |
# File 'lib/triviacrack/user.rb', line 36 def extra_shots @extra_shots end |
#facebook_id ⇒ Object (readonly)
Public: The Facebook ID of the user (nil if the user has not linked their Facebook account).
14 15 16 |
# File 'lib/triviacrack/user.rb', line 14 def facebook_id @facebook_id end |
#facebook_name ⇒ Object (readonly)
Public: The Facebook name of the user (nil if the user has not linked their Facebook account).
18 19 20 |
# File 'lib/triviacrack/user.rb', line 18 def facebook_name @facebook_name end |
#goal_points ⇒ Object (readonly)
Public: The user’s goal points.
49 50 51 |
# File 'lib/triviacrack/user.rb', line 49 def goal_points @goal_points end |
#id ⇒ Object (readonly)
Public: The unique identifier of the user.
7 8 9 |
# File 'lib/triviacrack/user.rb', line 7 def id @id end |
#level ⇒ Object (readonly)
Public: The user’s level.
39 40 41 |
# File 'lib/triviacrack/user.rb', line 39 def level @level end |
#level_points ⇒ Object (readonly)
Public: The experience points that the user has accumulated towards their next level.
43 44 45 |
# File 'lib/triviacrack/user.rb', line 43 def level_points @level_points end |
#level_progress ⇒ Object (readonly)
Public: The percentage progress towards the next level.
46 47 48 |
# File 'lib/triviacrack/user.rb', line 46 def level_progress @level_progress end |
#level_up ⇒ Object (readonly)
Public: Boolean indicating whether the user has leveled up.
52 53 54 |
# File 'lib/triviacrack/user.rb', line 52 def level_up @level_up end |
#lives ⇒ Object (readonly)
Public: The amount of lives available to the user.
24 25 26 |
# File 'lib/triviacrack/user.rb', line 24 def lives @lives end |
#max_lives ⇒ Object (readonly)
Public: The maximum number of lives that the user can have.
27 28 29 |
# File 'lib/triviacrack/user.rb', line 27 def max_lives @max_lives end |
#unlimited_lives ⇒ Object (readonly)
Public: Boolean indicating whether the user has unlimited lives.
30 31 32 |
# File 'lib/triviacrack/user.rb', line 30 def unlimited_lives @unlimited_lives end |
#username ⇒ Object (readonly)
Public: The unique username of the user.
10 11 12 |
# File 'lib/triviacrack/user.rb', line 10 def username @username end |
Instance Method Details
#start_new_game? ⇒ Boolean
Public: Returns true if the user has one or more lives, or has unlimited lives.
Examples
if user.start_new_game?
... start a new game ...
end
Returns true if the user can start a new game, false otherwise.
86 87 88 |
# File 'lib/triviacrack/user.rb', line 86 def start_new_game? @lives >= 1 || @unlimited_lives end |