class Fyodor::Library
Public Class Methods
new()
click to toggle source
# File lib/fyodor/library.rb, line 11 def initialize @books = [] @rej_empty = 0 end
Public Instance Methods
<<(entry)
click to toggle source
# File lib/fyodor/library.rb, line 16 def <<(entry) if entry.empty? @rej_empty += 1 return end book(entry.book_title, entry.book_author) << entry end
count_desc_unparsed()
click to toggle source
# File lib/fyodor/library.rb, line 29 def count_desc_unparsed reduce(0) { |acc, book| acc + book.count_desc_unparsed } end
count_entries()
click to toggle source
# File lib/fyodor/library.rb, line 33 def count_entries reduce(0) { |acc, book| acc + book.size } end
count_types()
click to toggle source
# File lib/fyodor/library.rb, line 25 def count_types reduce({}) { |acc, book| acc.merge(book.count_types) { |key, val1, val2| val1 + val2 } } end
rejected()
click to toggle source
# File lib/fyodor/library.rb, line 37 def rejected {empty: @rej_empty, dup: count_rej_dup} end
Private Instance Methods
book(title, author)
click to toggle source
# File lib/fyodor/library.rb, line 44 def book(title, author) book = find { |book| book.title == title && book.author == author } if book.nil? book = Book.new(title, author) @books << book end book end
count_rej_dup()
click to toggle source
# File lib/fyodor/library.rb, line 53 def count_rej_dup reduce(0) { |acc, book| acc + book.rej_dup } end