You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kubsu-sm5-ruby/lab2/test_data_list_student_shor...

30 lines
1.0 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

require_relative 'student_short'
require_relative 'data_list_student_short'
students = [
StudentShort.new(id: '1', surname_initials: 'Иванов И.И.', phone: '+79991112233'),
StudentShort.new(id: '2', surname_initials: 'Петров П.П.', telegram: '@petrov'),
StudentShort.new(id: '3', surname_initials: 'Сидоров С.С.', email: 'sidorov@mail.ru')
]
data_list = DataListStudentShort.new(students)
puts "Столбцы: #{data_list.get_names.inspect}"
table = data_list.get_data
(0...table.rows_count).each do |row|
puts (0...table.columns_count).map { |col| table.item(row, col) }.join(' | ')
end
new_students = [
StudentShort.new(id: '4', surname_initials: 'Новиков Н.Н.', phone: '+79994445566'),
StudentShort.new(id: '5', surname_initials: 'Кузнецов К.К.', email: 'kuznetsov@example.com')
]
data_list.items = new_students
puts "\nПосле замены:"
table = data_list.get_data
(0...table.rows_count).each do |row|
puts (0...table.columns_count).map { |col| table.item(row, col) }.join(' | ')
end