lib/book.rb in book-0.0.1 vs lib/book.rb in book-0.1.0
- old
+ new
@@ -1,3 +1,22 @@
-module Book
- # Your code goes here...
+class Book < Structure
+ key :edition
+ key :format
+ key :isbn
+ key :pages, :type => Integer
+ key :publisher
+ key :title
+ key :volumes, :type => Integer
+ key :year_published, :type => Integer
+ has_many :authors
+ has_many :identifiers
+ has_many :images
+ has_many :other_editions
+
+ def isbn
+ identifier =
+ identifiers.detect { |identifier| identifier.name == 'ISBN-13' } ||
+ identifiers.detect { |identifier| identifier.name == 'ISBN-10' }
+
+ identifier ? identifier.value : nil
+ end
end