Class: Olap::CellSet
- Inherits:
-
Object
- Object
- Olap::CellSet
- Defined in:
- lib/olap4r/cellset.rb
Instance Method Summary collapse
-
#axes ⇒ Object
Returns list of axes.
-
#initialize(cellset) ⇒ CellSet
constructor
:nodoc:.
-
#values(value_type = :formatted_value) ⇒ Object
Returns query values.
Constructor Details
#initialize(cellset) ⇒ CellSet
:nodoc:
3 4 5 |
# File 'lib/olap4r/cellset.rb', line 3 def initialize(cellset) # :nodoc: @cellset = cellset end |
Instance Method Details
#axes ⇒ Object
Returns list of axes
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/olap4r/cellset.rb', line 9 def axes @axes ||= @cellset.get_axes.map do |axis| { :axis => axis.get_axis_ordinal.to_s.downcase.to_sym, :values => axis.get_positions.map do |position| position.get_members.inject [] do |members, member| members << { :name => member., :unique_name => member.get_unique_name, :drillable => member.get_child_members.size > 0 } end end } end end |
#values(value_type = :formatted_value) ⇒ Object
Returns query values
Attributes
-
value_type
- Returned value type (:value or :formatted_value)
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/olap4r/cellset.rb', line 32 def values(value_type = :formatted_value) return @values unless @values.nil? @values = [] raise "olap4r doesn't support queries with more than 2 dimensions" if @cellset.get_axes.size > 2 columns = @cellset.get_axes[0].get_positions.size - 1 rows = @cellset.get_axes[1].get_positions.size - 1 cells = [] (0..columns).each do |i| (0..rows).each do |j| cells << [i, j] end end cells.each do |cell| @values[cell[1]] = [] if @values[cell[1]].nil? @values[cell[1]][cell[0]] = @cellset.get_cell(cell.map { |coord| coord.to_java(:int) }).send :"get_#{value_type}" @values[cell[1]][cell[0]] = "0" if @values[cell[1]][cell[0]].respond_to?(:empty?) && @values[cell[1]][cell[0]].empty? end @values end |