-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.rb
More file actions
27 lines (20 loc) · 677 Bytes
/
Copy pathmain.rb
File metadata and controls
27 lines (20 loc) · 677 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true
require './config'
def lib_methods(library)
library_top_readers = library.top_readers
puts 'Top readers: '
library_top_readers.each do |reader, count|
puts "Reader #{reader.name} has ordered #{count} books"
end
library_topbooks = library.most_popular_books
puts 'Most popular books: '
library_topbooks.each do |book, _author|
puts "Book: #{book.title}, Author: #{book.author.name} "
end
puts "Number of readers of the most popular book:
#{library.number_of_readers_of_the_most_popular_books(2)}"
end
library = Library.new
File.file?('data.yaml') ? library.load : library = seed
lib_methods(library)
library.save