X-Git-Url: http://jaekl.net/gitweb/?p=quanlib.git;a=blobdiff_plain;f=book.rb;h=3cf513957c0a2cc4173266857c95952b8cc0bb14;hp=f59b61a66ea44d17a86e7d999e34496b84fbea99;hb=b0ed11b1a03aab548e3c274dfd89732e8e11892f;hpb=e9d890ae4d346ce3abe93a8db94d3a3ddf9819d9
diff --git a/book.rb b/book.rb
index f59b61a..3cf5139 100644
--- a/book.rb
+++ b/book.rb
@@ -6,9 +6,12 @@ require 'author'
require 'cover'
class Book
+ @@DC_NS_URL = 'http://purl.org/dc/elements/1.1/'
+
def initialize(fileName)
@author = nil
@cover = nil
+ @description = nil
@path = fileName
@series = nil
@title = nil
@@ -36,7 +39,11 @@ class Book
return @cover
end
- def describe
+ def description
+ @description
+ end
+
+ def heading
result = []
if nil != @title
@@ -45,7 +52,7 @@ class Book
result.push('(Unknown title)')
end
if nil != @author
- result.push(@author.to_s())
+ result.push('by ' + @author.to_s() + '')
end
seriesInfo = []
@@ -191,13 +198,13 @@ class Book
#-------
# Author
- creator = opfDoc.css('dc|creator', 'dc' => 'http://purl.org/dc/elements/1.1/')
- if (nil != creator) and (creator.length > 0)
- roleNode = creator.attr('role')
- if nil != roleNode
- role = roleNode.value
- if ('aut' == role) and (creator.children.length > 0) and (nil != creator.children[0])
- name = creator.children[0].content
+ creators = opfDoc.css('dc|creator', 'dc' => @@DC_NS_URL)
+ if (creators.length > 0)
+ creator = creators[0]
+ if nil != creator
+ role = creator['opf:role']
+ if 'aut' == role
+ name = creator.content
parts = name.split(' ')
if parts.length > 1
surname = parts[-1]
@@ -210,6 +217,28 @@ class Book
end
end
+ #---------------------------------------
+ # Title
+
+ titles = opfDoc.css('dc|title', 'dc' => @@DC_NS_URL)
+ if titles.length > 0
+ title = titles[0]
+ if nil != title
+ @title = title.content
+ end
+ end
+
+ #---------------------------------------
+ # Description
+
+ descrNodes = opfDoc.css('dc|description', 'dc' => @@DC_NS_URL)
+ if (descrNodes.length > 0)
+ descrNode = descrNodes[0]
+ if nil != descrNode
+ @description = descrNode.content
+ end
+ end
+
#---------------------------------------
# Other metadata: series, volume, cover