Class: Fyodor::Library
- Inherits:
-
Object
- Object
- Fyodor::Library
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/fyodor/library.rb
Instance Method Summary collapse
- #<<(entry) ⇒ Object
- #count_desc_unparsed ⇒ Object
- #count_entries ⇒ Object
- #count_types ⇒ Object
-
#initialize ⇒ Library
constructor
A new instance of Library.
- #rejected ⇒ Object
Constructor Details
#initialize ⇒ Library
Returns a new instance of Library.
11 12 13 14 |
# File 'lib/fyodor/library.rb', line 11 def initialize @books = [] @rej_empty = 0 end |
Instance Method Details
#<<(entry) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/fyodor/library.rb', line 16 def <<(entry) if entry.empty? @rej_empty += 1 return end book(entry.book_title, entry.) << entry end |
#count_desc_unparsed ⇒ Object
29 30 31 |
# File 'lib/fyodor/library.rb', line 29 def count_desc_unparsed reduce(0) { |acc, book| acc + book.count_desc_unparsed } end |
#count_entries ⇒ Object
33 34 35 |
# File 'lib/fyodor/library.rb', line 33 def count_entries reduce(0) { |acc, book| acc + book.size } end |
#count_types ⇒ Object
25 26 27 |
# 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 ⇒ Object
37 38 39 |
# File 'lib/fyodor/library.rb', line 37 def rejected {empty: @rej_empty, dup: count_rej_dup} end |