Class: CSstats::Parser::Writer::Players

Inherits:
Object
  • Object
show all
Defined in:
lib/csstats/parser/writer/players.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ Players

Returns a new instance of Players.



9
10
11
# File 'lib/csstats/parser/writer/players.rb', line 9

def initialize(file_path)
  @file_path = file_path
end

Instance Attribute Details

#file_pathObject (readonly)

Returns the value of attribute file_path.



7
8
9
# File 'lib/csstats/parser/writer/players.rb', line 7

def file_path
  @file_path
end

Instance Method Details

#streamer(file) ⇒ Object



25
26
27
# File 'lib/csstats/parser/writer/players.rb', line 25

def streamer(file)
  CSstats::Parser::Writer::FileStreamer.new(file)
end

#write(players) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/csstats/parser/writer/players.rb', line 13

def write(players)
  file = File.new(file_path, 'w')

  streamer(file).write_short_data(11) # File version

  players.each do |player|
    CSstats::Parser::Writer::Player.new(streamer(file), player).write
  end

  file.close
end