OSDN Git Service

194468e1d19424821d77dc1f49b5ee1a482af4ed
[pettanr/pettanr.git] / lib / filer / summary.rb
1     class Summary
2       def initialize summary_conf
3         @summary_conf = summary_conf || {}
4         @type_conf = @summary_conf['type'] || 'none'
5         @type_method = self.type_method
6       end
7       
8       def type_method
9         case @type_conf
10         when 'none'
11           :type_none
12         when 'template'
13           :type_template
14         else
15           :type_none
16         end
17       end
18       
19       def type_none view, item, operators
20         ''
21       end
22       
23       def type_template view, item, operators
24         view.render item.path_name + '/' + @summary_conf['name'], :item => item
25       end
26       
27       def visible?
28         self.type_method != :type_none
29       end
30       
31       def render view, item, operators
32         self.__send__(@type_method, view, item, operators)
33       end
34       
35     end
36