Class: TxtStudentsListFormatStrategy
- Inherits:
-
StudentsListFormatStrategy
- Object
- StudentsListFormatStrategy
- TxtStudentsListFormatStrategy
- Defined in:
- lib/model_gem_source/students_list_format_strategy.rb
Instance Method Summary collapse
Instance Method Details
#read_from(filename) ⇒ Object
15 16 17 18 19 |
# File 'lib/model_gem_source/students_list_format_strategy.rb', line 15 def read_from(filename) File.read(filename) .split("\n") .map { |v| Student.from_string(v) } end |
#write_to(filename, students) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/model_gem_source/students_list_format_strategy.rb', line 21 def write_to(filename, students) File.open(filename, 'w') { |file| file.write( students.map { |student| student.get_info } .join("\n") ) } end |