Module: StudioGame::HandleCSV
- Included in:
- Game
- Defined in:
- lib/studio_game/handle_csv.rb
Instance Method Summary collapse
Instance Method Details
#load_players(from_file) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/studio_game/handle_csv.rb', line 3 def load_players(from_file) File.readlines(from_file).each do |line| player = Player.from_csv(line) add_player(player) end end |
#save_high_scores(to_file = "high_scores.txt") ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/studio_game/handle_csv.rb', line 10 def save_high_scores(to_file="high_scores.txt") File.open(to_file, "w") do |file| file.puts "#{self.title} High Scores:" self.players.sort.each do |player| file.puts player.print_score end end end |