Add support for classification of non-fiction books.
[quanlib.git] / classify / bookclass.rb
diff --git a/classify/bookclass.rb b/classify/bookclass.rb
new file mode 100644 (file)
index 0000000..20652dc
--- /dev/null
@@ -0,0 +1,70 @@
+# Classification information for a single book
+
+class BookClass
+  def initialize(grouping, title)
+    @author = nil
+    @ddc = nil
+    @grouping = grouping
+    @fast = []
+    @lcc = nil
+    @title = title
+  end
+
+  def author 
+    @author 
+  end
+  def author=(value) 
+    @author = value 
+  end
+  def ddc 
+    @ddc 
+  end
+  def ddc=(value) 
+    @ddc = value 
+  end
+  def fast 
+    @fast 
+  end
+  def grouping
+    @grouping
+  end
+  def lcc 
+    @lcc 
+  end
+  def lcc=(value) 
+    @lcc = value 
+  end
+  def title 
+    @title 
+  end
+
+  def add_fast(id)
+    @fast.push(id)
+  end
+
+  def inspect 
+    data = []
+
+    if nil != @author_name 
+      data.push('author_name="' + @author_name + '"') 
+    end
+    if nil != @ddc
+      data.push('ddc="' + @ddc + '"') 
+    end
+    if nil != @grouping 
+      data.push('grouping="' + @grouping + '"') 
+    end
+    if nil != @fast 
+      data.push('fast=' + @fast.inspect) 
+    end
+    if nil != @lcc 
+      data.push('lcc="' + @lcc + '"') 
+    end
+    if nil != @title 
+      data.push('title="' + @title + '"') 
+    end
+
+    return '(BookClass:' + data.join(',') + ')'
+  end
+end
+