Sha256: 22d30616334f17f7ad5ae06b7851d0e26a7a043ecaee175b3a8c148f9ce96875
Contents?: true
Size: 590 Bytes
Versions: 1
Compression:
Stored size: 590 Bytes
Contents
class FindReadersNumberForBook def self.perform(library, book) new(library, book).perform end def initialize(library, book) @library = library @book = book end def perform find_the_number_of_readers end private def find_the_number_of_readers book_readers = [] library.orders.each do |order| book_readers.push(order.reader) if new_reader?(book_readers, order) end book_readers.size end def new_reader?(found_readers, order) order.book == book && !found_readers.include?(order.reader) end attr_reader :library, :book end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bokov_library-1.0.0 | lib/find_readers_number_for_book.rb |