Class: Openra::Replays::Replay
- Inherits:
-
Object
- Object
- Openra::Replays::Replay
- Defined in:
- lib/openra/replays/replay.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
- #duration ⇒ Object
- #end_time ⇒ Object
-
#initialize(filename) ⇒ Replay
constructor
A new instance of Replay.
- #map_id ⇒ Object
- #map_title ⇒ Object
- #metadata ⇒ Object
- #mod ⇒ Object
- #orders ⇒ Object
- #start_time ⇒ Object
- #version ⇒ Object
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
#file ⇒ Object (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
#duration ⇒ Object
48 49 50 |
# File 'lib/openra/replays/replay.rb', line 48 def duration @duration ||= (end_time - start_time).to_i end |
#end_time ⇒ Object
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_id ⇒ Object
26 27 28 |
# File 'lib/openra/replays/replay.rb', line 26 def map_id @map_id ||= ['Root']['MapUid'] end |
#map_title ⇒ Object
30 31 32 |
# File 'lib/openra/replays/replay.rb', line 30 def map_title @map_title ||= ['Root']['MapTitle'] end |
#metadata ⇒ Object
10 11 12 |
# File 'lib/openra/replays/replay.rb', line 10 def ||= Openra::YAML.load(file..data) end |
#mod ⇒ Object
18 19 20 |
# File 'lib/openra/replays/replay.rb', line 18 def mod @mod ||= ['Root']['Mod'] end |
#orders ⇒ Object
14 15 16 |
# File 'lib/openra/replays/replay.rb', line 14 def orders @orders ||= file.orders end |
#start_time ⇒ Object
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 |
#version ⇒ Object
22 23 24 |
# File 'lib/openra/replays/replay.rb', line 22 def version @version ||= ['Root']['Version'] end |