Class: Headcount::Persistence::File
- Inherits:
-
Object
- Object
- Headcount::Persistence::File
- Defined in:
- lib/headcount/persistence/file.rb
Instance Method Summary collapse
-
#initialize(path, format) ⇒ File
constructor
A new instance of File.
- #save(headcounts, options = {}) ⇒ Object
Constructor Details
#initialize(path, format) ⇒ File
Returns a new instance of File.
4 5 6 7 |
# File 'lib/headcount/persistence/file.rb', line 4 def initialize(path, format) @path = path @format = format end |
Instance Method Details
#save(headcounts, options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/headcount/persistence/file.rb', line 9 def save(headcounts, = {}) ::File.delete(@path) if ::File.exists?(@path) if [:reset] ::File.open(@path, 'a') do |file| headcounts.each do |headcount| file.puts headcount.to_json end end end |