Class: Crosstab::Group
Instance Method Summary collapse
-
#children(value = nil) ⇒ Object
attr_reader for the children attribute which should contain an empty array, or a list of rows or columns.
-
#qualifies?(record) ⇒ Boolean
Returns true when a record passes a qualification filter belonging to any child of the group.
Methods inherited from Row
Methods inherited from Generic
#printed?, #qualification, #title
Constructor Details
This class inherits a constructor from Crosstab::Row
Instance Method Details
#children(value = nil) ⇒ Object
attr_reader for the children attribute which should contain an empty array, or a list of rows or columns
Example:
children
#=> []
children [ Crosstab::Row("Male", :a => 1) ]
children.first.title
#=> "Male"
15 16 17 18 19 20 21 |
# File 'lib/crosstab/group.rb', line 15 def children(value=nil) if value @children = value else @children ||= [] end end |
#qualifies?(record) ⇒ Boolean
Returns true when a record passes a qualification filter belonging to any child of the group. This is how subtotals work.
25 26 27 |
# File 'lib/crosstab/group.rb', line 25 def qualifies?(record) children.any? { |child| child.qualifies? record } end |