Class: Flox::Score

Inherits:
Object
  • Object
show all
Defined in:
lib/flox/score.rb

Overview

Provides information about the value and origin of one posted score entry.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Score

Returns a new instance of Score.

Parameters:

  • data (Hash)

    the contents of the score as given by the Flox server.



26
27
28
29
30
31
32
# File 'lib/flox/score.rb', line 26

def initialize(data)
  @player_id = data[:playerId].to_s
  @player_name = data[:playerName].to_s
  @value = data[:value].to_i
  @country = data[:country].to_s
  @created_at = Time.parse(data[:createdAt].to_s)
end

Instance Attribute Details

#countryString (readonly)

Returns the country from which the score originated, in a two-letter country code.

Returns:

  • (String)

    the country from which the score originated, in a two-letter country code.



20
21
22
# File 'lib/flox/score.rb', line 20

def country
  @country
end

#created_atTime (readonly)

Returns the date at which the score was posted.

Returns:

  • (Time)

    the date at which the score was posted.



23
24
25
# File 'lib/flox/score.rb', line 23

def created_at
  @created_at
end

#player_idString (readonly)

Returns the ID of the player who posted the score. Note that this could be a guest player unknown to the server.

Returns:

  • (String)

    the ID of the player who posted the score. Note that this could be a guest player unknown to the server.



10
11
12
# File 'lib/flox/score.rb', line 10

def player_id
  @player_id
end

#player_nameString (readonly)

Returns the name of the player who posted the score.

Returns:

  • (String)

    the name of the player who posted the score.



13
14
15
# File 'lib/flox/score.rb', line 13

def player_name
  @player_name
end

#valueFixnum (readonly)

Returns the actual score.

Returns:

  • (Fixnum)

    the actual score.



16
17
18
# File 'lib/flox/score.rb', line 16

def value
  @value
end