Class: Demoman::DemoFile
- Inherits:
-
Object
- Object
- Demoman::DemoFile
- Defined in:
- lib/demoman/demo_file.rb
Instance Attribute Summary collapse
-
#demo_protocol ⇒ Object
readonly
Returns the value of attribute demo_protocol.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#frames ⇒ Object
readonly
Returns the value of attribute frames.
-
#game_dir ⇒ Object
readonly
Returns the value of attribute game_dir.
-
#map ⇒ Object
readonly
Returns the value of attribute map.
-
#network_protocol ⇒ Object
readonly
Returns the value of attribute network_protocol.
-
#player_name ⇒ Object
readonly
Returns the value of attribute player_name.
-
#server_address ⇒ Object
readonly
Returns the value of attribute server_address.
-
#sign_on_length ⇒ Object
readonly
Returns the value of attribute sign_on_length.
-
#ticks ⇒ Object
readonly
Returns the value of attribute ticks.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(file = nil) ⇒ DemoFile
constructor
A new instance of DemoFile.
- #parse_data(data) ⇒ Object
Constructor Details
#initialize(file = nil) ⇒ DemoFile
Returns a new instance of DemoFile.
7 8 9 10 11 12 13 14 15 |
# File 'lib/demoman/demo_file.rb', line 7 def initialize(file=nil) unless file.nil? io = File.new(file, "r") data = io.sysread(4096) parse_data data end end |
Instance Attribute Details
#demo_protocol ⇒ Object (readonly)
Returns the value of attribute demo_protocol.
5 6 7 |
# File 'lib/demoman/demo_file.rb', line 5 def demo_protocol @demo_protocol end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
5 6 7 |
# File 'lib/demoman/demo_file.rb', line 5 def duration @duration end |
#frames ⇒ Object (readonly)
Returns the value of attribute frames.
5 6 7 |
# File 'lib/demoman/demo_file.rb', line 5 def frames @frames end |
#game_dir ⇒ Object (readonly)
Returns the value of attribute game_dir.
5 6 7 |
# File 'lib/demoman/demo_file.rb', line 5 def game_dir @game_dir end |
#map ⇒ Object (readonly)
Returns the value of attribute map.
5 6 7 |
# File 'lib/demoman/demo_file.rb', line 5 def map @map end |
#network_protocol ⇒ Object (readonly)
Returns the value of attribute network_protocol.
5 6 7 |
# File 'lib/demoman/demo_file.rb', line 5 def network_protocol @network_protocol end |
#player_name ⇒ Object (readonly)
Returns the value of attribute player_name.
5 6 7 |
# File 'lib/demoman/demo_file.rb', line 5 def player_name @player_name end |
#server_address ⇒ Object (readonly)
Returns the value of attribute server_address.
5 6 7 |
# File 'lib/demoman/demo_file.rb', line 5 def server_address @server_address end |
#sign_on_length ⇒ Object (readonly)
Returns the value of attribute sign_on_length.
5 6 7 |
# File 'lib/demoman/demo_file.rb', line 5 def sign_on_length @sign_on_length end |
#ticks ⇒ Object (readonly)
Returns the value of attribute ticks.
5 6 7 |
# File 'lib/demoman/demo_file.rb', line 5 def ticks @ticks end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/demoman/demo_file.rb', line 5 def type @type end |
Instance Method Details
#parse_data(data) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/demoman/demo_file.rb', line 17 def parse_data(data) demodata = data.unpack("A8/I/I/A260/A260/A260/A260/f/I/I/I/") @type = demodata[0] @demo_protocol = demodata[1] @network_protocol = demodata[2] @server_address = demodata[3] @player_name = demodata[4] @map = demodata[5] @game_dir = demodata[6] @duration = demodata[7] @ticks = demodata[8] @frames = demodata[9] @sign_on_length = demodata[10] nil end |