Add `arrived` attribute (file creation timestamp) to books table.
[quanlib.git] / classification.rb
1
2 class Classification
3   def initialize(ddc, lcc, author_grouping, author, title_grouping, title)
4     @id = nil
5     @ddc = ddc
6     @lcc = lcc
7     @author_grouping = author_grouping
8     @author = author
9     @title_grouping = title_grouping
10     @title = title
11   end
12
13   def id
14     @id
15   end
16   def id=(value)
17     @id = value
18   end
19
20   def ddc
21     @ddc
22   end
23   def lcc
24     @lcc
25   end
26   def author_grouping
27     @author_grouping
28   end
29   def author
30     @author
31   end
32   def 
33
34   def inspect
35     data = []
36  
37     if nil != @ddc
38       data.push('Dewey=' + @ddc.to_s)
39     end
40     if nil != @lcc
41       data.push('LCC=' + @lcc.to_s)
42     end
43     if nil != @author_grouping
44       data.push('author_grouping=' + @author_grouping.to_s)
45     end
46     if nil != @author
47       data.push('author=' + @author.to_s)
48     end
49     if nil != @title_grouping
50       data.push('title_grouping=' + @title_grouping.to_s)
51     end
52     if nil != @title
53       data.push('title=' + @title)
54     end
55
56     return '(Classification:' + data.join(',') + ')'
57   end
58
59   def to_s
60     inspect
61   end
62
63   protected
64   def reading_to_sort_order(reading_order)
65     sort_order = reading_order
66
67     parts = reading_order.split(' ')
68     if parts.length > 1
69       sort_order = parts[-1] + ', ' + parts[0..-2].join(' ')
70     end
71
72     return sort_order
73   end
74 end
75