class TriviaCrack::User

Attributes

coins[R]

Public: The amount of coins that the user has accumulated.

country[R]

Public: The country code of the user's country.

extra_shots[R]

Public: The number of extra shots available to the user.

facebook_id[R]

Public: The Facebook ID of the user (nil if the user has not linked their Facebook account).

facebook_name[R]

Public: The Facebook name of the user (nil if the user has not linked their Facebook account).

goal_points[R]

Public: The user's goal points.

id[R]

Public: The unique identifier of the user.

level[R]

Public: The user's level.

level_points[R]

Public: The experience points that the user has accumulated towards their next level.

level_progress[R]

Public: The percentage progress towards the next level.

level_up[R]

Public: Boolean indicating whether the user has leveled up.

lives[R]

Public: The amount of lives available to the user.

max_lives[R]

Public: The maximum number of lives that the user can have.

unlimited_lives[R]

Public: Boolean indicating whether the user has unlimited lives.

username[R]

Public: The unique username of the user.

Public Class Methods

new(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) click to toggle source
# 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

Public Instance Methods

start_new_game?() click to toggle source

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.

# File lib/triviacrack/user.rb, line 86
def start_new_game?
  @lives >= 1 || @unlimited_lives
end