Class: Cubicle::Data::Table
- Inherits:
-
Array
- Object
- Array
- Cubicle::Data::Table
- Defined in:
- lib/cubicle/data/table.rb
Instance Attribute Summary collapse
-
#dimensions ⇒ Object
readonly
Returns the value of attribute dimensions.
-
#measures ⇒ Object
readonly
Returns the value of attribute measures.
-
#time_dimension_name ⇒ Object
readonly
Returns the value of attribute time_dimension_name.
-
#time_period ⇒ Object
readonly
Returns the value of attribute time_period.
-
#time_range ⇒ Object
readonly
Returns the value of attribute time_range.
-
#total_count ⇒ Object
readonly
Returns the value of attribute total_count.
Instance Method Summary collapse
- #dimension_names ⇒ Object
- #hierarchize(*args) ⇒ Object (also: #hierarchize_by, #by)
-
#initialize(query, query_results, total_count = nil) ⇒ Table
constructor
A new instance of Table.
- #measure_names ⇒ Object
- #records_per_page=(records_per_page) ⇒ Object
- #total_pages ⇒ Object
Constructor Details
#initialize(query, query_results, total_count = nil) ⇒ Table
Returns a new instance of Table.
6 7 8 9 10 11 12 13 14 |
# File 'lib/cubicle/data/table.rb', line 6 def initialize(query,query_results,total_count = nil) @dimensions = Marshal.load(Marshal.dump(query.dimensions)) @measures = Marshal.load(Marshal.dump(query.measures)) @time_dimension_name = query.time_dimension.name if query.respond_to?(:time_dimension) && query.time_dimension @time_period = query.time_period if query.respond_to?(:time_period) @time_range = query.time_range if query.respond_to?(:time_range) extract_data(query,query_results) @total_count = total_count if total_count end |
Instance Attribute Details
#dimensions ⇒ Object (readonly)
Returns the value of attribute dimensions.
4 5 6 |
# File 'lib/cubicle/data/table.rb', line 4 def dimensions @dimensions end |
#measures ⇒ Object (readonly)
Returns the value of attribute measures.
4 5 6 |
# File 'lib/cubicle/data/table.rb', line 4 def measures @measures end |
#time_dimension_name ⇒ Object (readonly)
Returns the value of attribute time_dimension_name.
4 5 6 |
# File 'lib/cubicle/data/table.rb', line 4 def time_dimension_name @time_dimension_name end |
#time_period ⇒ Object (readonly)
Returns the value of attribute time_period.
4 5 6 |
# File 'lib/cubicle/data/table.rb', line 4 def time_period @time_period end |
#time_range ⇒ Object (readonly)
Returns the value of attribute time_range.
4 5 6 |
# File 'lib/cubicle/data/table.rb', line 4 def time_range @time_range end |
#total_count ⇒ Object (readonly)
Returns the value of attribute total_count.
4 5 6 |
# File 'lib/cubicle/data/table.rb', line 4 def total_count @total_count end |
Instance Method Details
#dimension_names ⇒ Object
16 17 18 |
# File 'lib/cubicle/data/table.rb', line 16 def dimension_names @dimensions.map{|d|d.name} end |
#hierarchize(*args) ⇒ Object Also known as: hierarchize_by, by
24 25 26 |
# File 'lib/cubicle/data/table.rb', line 24 def hierarchize(*args) Cubicle::Data::Hierarchy.hierarchize_table(self,args) end |
#measure_names ⇒ Object
20 21 22 |
# File 'lib/cubicle/data/table.rb', line 20 def measure_names @measures.map{|m|m.name} end |
#records_per_page=(records_per_page) ⇒ Object
30 31 32 |
# File 'lib/cubicle/data/table.rb', line 30 def records_per_page=(records_per_page) @records_per_page=records_per_page end |
#total_pages ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/cubicle/data/table.rb', line 34 def total_pages if (!defined?(@total_count)) raise "Cannot find the total number of pages without setting the total count" end if (!defined?(@records_per_page)) raise "Cannot find the total number of pages without setting the number of records per page" end (@total_count.to_f / @records_per_page.to_f).ceil end |