Class: Openra::Replays::Replay

Inherits:
Object
  • Object
show all
Defined in:
lib/openra/replays/replay.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Replay

Returns a new instance of Replay.



6
7
8
# File 'lib/openra/replays/replay.rb', line 6

def initialize(filename)
  @file = Openra::Replays::File.new(filename)
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



4
5
6
# File 'lib/openra/replays/replay.rb', line 4

def file
  @file
end

Instance Method Details

#durationObject



48
49
50
# File 'lib/openra/replays/replay.rb', line 48

def duration
  @duration ||= (end_time - start_time).to_i
end

#end_timeObject



41
42
43
44
45
46
# File 'lib/openra/replays/replay.rb', line 41

def end_time
  @end_time ||= ::DateTime.strptime(
    ['Root']['EndTimeUtc'],
    '%Y-%m-%d %H-%M-%S'
  ).to_time
end

#map_idObject



26
27
28
# File 'lib/openra/replays/replay.rb', line 26

def map_id
  @map_id ||= ['Root']['MapUid']
end

#map_titleObject



30
31
32
# File 'lib/openra/replays/replay.rb', line 30

def map_title
  @map_title ||= ['Root']['MapTitle']
end

#metadataObject



10
11
12
# File 'lib/openra/replays/replay.rb', line 10

def 
   ||= Openra::YAML.load(file..data)
end

#modObject



18
19
20
# File 'lib/openra/replays/replay.rb', line 18

def mod
  @mod ||= ['Root']['Mod']
end

#ordersObject



14
15
16
# File 'lib/openra/replays/replay.rb', line 14

def orders
  @orders ||= file.orders
end

#start_timeObject



34
35
36
37
38
39
# File 'lib/openra/replays/replay.rb', line 34

def start_time
  @start_time ||= ::DateTime.strptime(
    ['Root']['StartTimeUtc'],
    '%Y-%m-%d %H-%M-%S'
  ).to_time
end

#versionObject



22
23
24
# File 'lib/openra/replays/replay.rb', line 22

def version
  @version ||= ['Root']['Version']
end