Add DDC and LCC info to book headers in page display.
[quanlib.git] / classification.rb
diff --git a/classification.rb b/classification.rb
new file mode 100644 (file)
index 0000000..2061e46
--- /dev/null
@@ -0,0 +1,75 @@
+
+class Classification
+  def initialize(ddc, lcc, author_grouping, author, title_grouping, title)
+    @id = nil
+    @ddc = ddc
+    @lcc = lcc
+    @author_grouping = author_grouping
+    @author = author
+    @title_grouping = title_grouping
+    @title = title
+  end
+
+  def id
+    @id
+  end
+  def id=(value)
+    @id = value
+  end
+
+  def ddc
+    @ddc
+  end
+  def lcc
+    @lcc
+  end
+  def author_grouping
+    @author_grouping
+  end
+  def author
+    @author
+  end
+  def 
+
+  def inspect
+    data = []
+    if nil != @ddc
+      data.push('Dewey=' + @ddc.to_s)
+    end
+    if nil != @lcc
+      data.push('LCC=' + @lcc.to_s)
+    end
+    if nil != @author_grouping
+      data.push('author_grouping=' + @author_grouping.to_s)
+    end
+    if nil != @author
+      data.push('author=' + @author.to_s)
+    end
+    if nil != @title_grouping
+      data.push('title_grouping=' + @title_grouping.to_s)
+    end
+    if nil != @title
+      data.push('title=' + @title)
+    end
+
+    return '(Classification:' + data.join(',') + ')'
+  end
+
+  def to_s
+    inspect
+  end
+
+  protected
+  def reading_to_sort_order(reading_order)
+    sort_order = reading_order
+
+    parts = reading_order.split(' ')
+    if parts.length > 1
+      sort_order = parts[-1] + ', ' + parts[0..-2].join(' ')
+    end
+
+    return sort_order
+  end
+end
+