Class: XMLA::Cube

Inherits:
Object
  • Object
show all
Defined in:
lib/cube/cube.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#catalogObject (readonly)

Returns the value of attribute catalog.



15
16
17
# File 'lib/cube/cube.rb', line 15

def catalog
  @catalog
end

#queryObject (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

.execute_members(query, catalog = XMLA.catalog) ⇒ Object



21
22
23
# File 'lib/cube/cube.rb', line 21

def Cube.execute_members(query, catalog = XMLA.catalog)
  Cube.new(query, catalog).axes
end

.execute_scalar(query, catalog = XMLA.catalog) ⇒ Object



25
26
27
# File 'lib/cube/cube.rb', line 25

def Cube.execute_scalar(query, catalog = XMLA.catalog)
  BigDecimal.new Cube.new(query, catalog).as_table[0]
end

Instance Method Details

#as_tableObject



29
30
31
32
# File 'lib/cube/cube.rb', line 29

def as_table 
  return [table] if y_size == 0
  clean_table(table, y_size).reduce([]) { |result, row| result << row.flatten }
end

#axesObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/cube/cube.rb', line 34

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
      else
        y << data.select { |item_data| item_data.class == Hash }.reduce([]) do |z,item_data|
          z << item_data
          # z << item_data[:caption].strip 
        end
      end
    }
  end
end