class Fyodor::Book
Attributes
rej_dup[R]
title[R]
Public Class Methods
new(title, author=nil)
click to toggle source
# File lib/fyodor/book.rb, line 13 def initialize(title, author=nil) raise "Book title can't be empty" if title.to_s.empty? @title = title @author = author @entries = Set.new @rej_dup = 0 end
Public Instance Methods
<<(entry)
click to toggle source
# File lib/fyodor/book.rb, line 22 def <<(entry) return if entry.empty? # #add? returns nil if the entry was duplicated @rej_dup += 1 if @entries.add?(entry).nil? end
count_desc_unparsed()
click to toggle source
# File lib/fyodor/book.rb, line 33 def count_desc_unparsed count { |entry| ! entry.desc_parsed? } end
count_types()
click to toggle source
# File lib/fyodor/book.rb, line 28 def count_types list = group_by(&:type).map { |k, v| [k, v.size] } Hash[list] end