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
rubocop:disable Metrics/MethodLength, Metrics/ParameterLists.
-
#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
rubocop:disable Metrics/MethodLength, Metrics/ParameterLists
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/triviacrack/user.rb', line 55 def initialize(id:, username: nil, facebook_id: nil, facebook_name: nil, # rubocop:disable Metrics/MethodLength, Metrics/ParameterLists 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.
22 23 24 |
# File 'lib/triviacrack/user.rb', line 22 def coins @coins end |
#country ⇒ Object (readonly)
Public: The country code of the user’s country.
34 35 36 |
# File 'lib/triviacrack/user.rb', line 34 def country @country end |
#extra_shots ⇒ Object (readonly)
Public: The number of extra shots available to the user.
37 38 39 |
# File 'lib/triviacrack/user.rb', line 37 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).
15 16 17 |
# File 'lib/triviacrack/user.rb', line 15 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).
19 20 21 |
# File 'lib/triviacrack/user.rb', line 19 def facebook_name @facebook_name end |
#goal_points ⇒ Object (readonly)
Public: The user’s goal points.
50 51 52 |
# File 'lib/triviacrack/user.rb', line 50 def goal_points @goal_points end |
#id ⇒ Object (readonly)
Public: The unique identifier of the user.
8 9 10 |
# File 'lib/triviacrack/user.rb', line 8 def id @id end |
#level ⇒ Object (readonly)
Public: The user’s level.
40 41 42 |
# File 'lib/triviacrack/user.rb', line 40 def level @level end |
#level_points ⇒ Object (readonly)
Public: The experience points that the user has accumulated towards their next level.
44 45 46 |
# File 'lib/triviacrack/user.rb', line 44 def level_points @level_points end |
#level_progress ⇒ Object (readonly)
Public: The percentage progress towards the next level.
47 48 49 |
# File 'lib/triviacrack/user.rb', line 47 def level_progress @level_progress end |
#level_up ⇒ Object (readonly)
Public: Boolean indicating whether the user has leveled up.
53 54 55 |
# File 'lib/triviacrack/user.rb', line 53 def level_up @level_up end |
#lives ⇒ Object (readonly)
Public: The amount of lives available to the user.
25 26 27 |
# File 'lib/triviacrack/user.rb', line 25 def lives @lives end |
#max_lives ⇒ Object (readonly)
Public: The maximum number of lives that the user can have.
28 29 30 |
# File 'lib/triviacrack/user.rb', line 28 def max_lives @max_lives end |
#unlimited_lives ⇒ Object (readonly)
Public: Boolean indicating whether the user has unlimited lives.
31 32 33 |
# File 'lib/triviacrack/user.rb', line 31 def unlimited_lives @unlimited_lives end |
#username ⇒ Object (readonly)
Public: The unique username of the user.
11 12 13 |
# File 'lib/triviacrack/user.rb', line 11 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.
87 88 89 |
# File 'lib/triviacrack/user.rb', line 87 def start_new_game? @lives >= 1 || @unlimited_lives end |