Class: ReminderFile
- Inherits:
-
Object
- Object
- ReminderFile
- Defined in:
- lib/forgetful/extensions/csv/reminder_file.rb
Instance Attribute Summary collapse
-
#delay ⇒ Object
readonly
Returns the value of attribute delay.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Instance Method Summary collapse
-
#initialize(filename, delay = 0..0) ⇒ ReminderFile
constructor
A new instance of ReminderFile.
- #read ⇒ Object
- #write(reminders) ⇒ Object
Constructor Details
#initialize(filename, delay = 0..0) ⇒ ReminderFile
Returns a new instance of ReminderFile.
6 7 8 9 |
# File 'lib/forgetful/extensions/csv/reminder_file.rb', line 6 def initialize(filename, delay=0..0) @filename = filename @delay = delay end |
Instance Attribute Details
#delay ⇒ Object (readonly)
Returns the value of attribute delay.
4 5 6 |
# File 'lib/forgetful/extensions/csv/reminder_file.rb', line 4 def delay @delay end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
4 5 6 |
# File 'lib/forgetful/extensions/csv/reminder_file.rb', line 4 def filename @filename end |
Instance Method Details
#read ⇒ Object
11 12 13 14 15 |
# File 'lib/forgetful/extensions/csv/reminder_file.rb', line 11 def read File.open(filename) do |file| parse_csv(file) end end |
#write(reminders) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/forgetful/extensions/csv/reminder_file.rb', line 17 def write(reminders) data = CSV.generate do |csv| reminders.each do |reminder| csv << reminder.to_csv end end File.open(filename, "w") do |file| file.write(data) end end |