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.



8
9
10
# File 'lib/openra/replays/replay.rb', line 8

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

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



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

def file
  @file
end

Instance Method Details

#each_order(&block) ⇒ Object



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

def each_order(&block)
  file.each_order(&block)
end

#file_hashObject



12
13
14
# File 'lib/openra/replays/replay.rb', line 12

def file_hash
  file.generate_hash
end

#metadataObject



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

def 
  @metadata ||= Openra::Struct::Metadata.new(
    Openra::MiniYAML.load(file..data)
  )
end

#player(index) ⇒ Object



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

def player(index)
  players.find do |candidate|
    candidate.client_index == index
  end
end

#playersObject



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

def players
  .players
end