Class: JsonFileWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/asciinema/json_file_writer.rb

Instance Method Summary collapse

Instance Method Details

#write_enumerable(file, array) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/asciinema/json_file_writer.rb', line 3

def write_enumerable(file, array)
  first = true
  file << '['

  array.each do |item|
    if first
      first = false
    else
      file << ','
    end

    file << item.to_json
  end

  file << ']'
  file.close
end