Class: QuakeliveApi::GameTime

Inherits:
Object
  • Object
show all
Defined in:
lib/quakelive_api/game_time.rb

Defined Under Namespace

Classes: Interval

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(unparsed_string) ⇒ GameTime

accepts unparsed string directly from QL profile, for example:

  • Ranked Time: 21:50 Unranked Time: 04:54

  • Ranked Time: 50.06:18:30 Unranked Time: 02:31:02



14
15
16
17
18
19
20
# File 'lib/quakelive_api/game_time.rb', line 14

def initialize(unparsed_string)
  matches = unparsed_string.match(/Ranked Time: ([\d:.]+) Unranked Time: ([\d:.]+)/)
  return unless matches

  @ranked   = reverse_match(matches[1])
  @unranked = reverse_match(matches[2])
end

Instance Attribute Details

#rankedObject

Returns the value of attribute ranked.



3
4
5
# File 'lib/quakelive_api/game_time.rb', line 3

def ranked
  @ranked
end

#unrankedObject

Returns the value of attribute unranked.



3
4
5
# File 'lib/quakelive_api/game_time.rb', line 3

def unranked
  @unranked
end

Instance Method Details

#==(other) ⇒ Object



22
23
24
# File 'lib/quakelive_api/game_time.rb', line 22

def ==(other)
  return ranked == other.ranked && unranked == other.unranked
end