Class: Rose::Proxy::Summary
Overview
This class is used by the DSL to collect summary attributes
Instance Attribute Summary collapse
-
#column_name ⇒ Object
readonly
Returns the value of attribute column_name.
Attributes inherited from Row
#attributes, #identity_attribute
Instance Method Summary collapse
-
#initialize(column_name) ⇒ Summary
constructor
A new instance of Summary.
- #on(table) ⇒ Object
Methods inherited from Row
#column, #identity, name_and_title
Constructor Details
#initialize(column_name) ⇒ Summary
Returns a new instance of Summary.
55 56 57 58 |
# File 'lib/rose/proxy.rb', line 55 def initialize(column_name) super() @column_name = column_name end |
Instance Attribute Details
#column_name ⇒ Object (readonly)
Returns the value of attribute column_name.
53 54 55 |
# File 'lib/rose/proxy.rb', line 53 def column_name @column_name end |
Instance Method Details
#on(table) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/rose/proxy.rb', line 60 def on(table) rows = table.column(@column_name).uniq.inject([]) do |rows, group| rows << @attributes.row { |attr| gr = table.grouped_rows({@column_name => group}, attr.column_name) attr.evaluate(gr) }.merge(@column_name => group) end Ruport::Data::RoseTable.new(:column_names => [@column_name] | @attributes.column_names).tap do |table| rows.each { |row| table << row } end end |