Class: XMLA::Cube
- Inherits:
-
Object
- Object
- XMLA::Cube
- Defined in:
- lib/cube/cube.rb
Instance Attribute Summary collapse
-
#catalog ⇒ Object
readonly
Returns the value of attribute catalog.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
Class Method Summary collapse
- .execute(query, catalog = XMLA.catalog) ⇒ Object
- .execute_members(query, catalog = XMLA.catalog) ⇒ Object
- .execute_scalar(query, catalog = XMLA.catalog) ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#catalog ⇒ Object (readonly)
Returns the value of attribute catalog.
15 16 17 |
# File 'lib/cube/cube.rb', line 15 def catalog @catalog end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
15 16 17 |
# File 'lib/cube/cube.rb', line 15 def query @query end |
Class Method Details
.execute(query, catalog = XMLA.catalog) ⇒ Object
17 18 19 |
# File 'lib/cube/cube.rb', line 17 def Cube.execute(query, catalog = XMLA.catalog) OlapResult.new(Cube.new(query, catalog).as_table) end |
Instance Method Details
#as_table ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/cube/cube.rb', line 29 def as_table return [table] if y_size == 0 clean_table(table).reduce([]) { |result, row| flat_row = row.flatten result << flat_row unless flat_row.all?(&:blank?) result } end |
#axes ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/cube/cube.rb', line 38 def axes axes = all_axes.select { |axe| axe[:@name] != "SlicerAxis" } @axes ||= axes.reduce([]) do |result, axe| result << tuple(axe).reduce([]) { |y, member| data = (member[0] == :member) ? member[1] : member[:member] if ( data.class == Hash || data.size == 1 ) # y << [data[:caption].strip].flatten y << [data].flatten # y << [Hash[*data.map{|d| [d.first,d.last.to_s]}.flatten]].flatten else y << data.select { |item_data| item_data.class == Hash }.reduce([]) do |z,item_data| z << [item_data].flatten # z << item_data[:caption].strip end end } end end |