Class: Chicago::Schema::PivotedColumn

Inherits:
QueryColumn show all
Defined in:
lib/chicago/schema/query_column.rb

Instance Method Summary collapse

Methods inherited from QueryColumn

column, #filter_dataset, #method_missing

Constructor Details

#initialize(column, pivoted_by, index, value, unit = 0) ⇒ PivotedColumn

Returns a new instance of PivotedColumn.



177
178
179
180
181
182
183
# File 'lib/chicago/schema/query_column.rb', line 177

def initialize(column, pivoted_by, index, value, unit=0)
  super column
  @pivoted_column = pivoted_by
  @index = index
  @value = value
  @unit = unit
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Chicago::Schema::QueryColumn

Instance Method Details

#calculate(operation) ⇒ Object



185
186
187
# File 'lib/chicago/schema/query_column.rb', line 185

def calculate(operation)
  CalculatedColumn.make(operation, self)
end

#column_aliasObject



197
198
199
# File 'lib/chicago/schema/query_column.rb', line 197

def column_alias
  "#{@column.column_alias}:#{@pivoted_column.column_alias}.#{@index}".to_sym
end

#count_nameObject



209
210
211
# File 'lib/chicago/schema/query_column.rb', line 209

def count_name
  :if.sql_function({@pivoted_column.select_name => @value}, @column.count_name, @unit)
end

#group_nameObject



201
202
203
# File 'lib/chicago/schema/query_column.rb', line 201

def group_name
  nil
end

#labelObject



189
190
191
# File 'lib/chicago/schema/query_column.rb', line 189

def label
  [@column.label, @value]
end

#ownerObject



193
194
195
# File 'lib/chicago/schema/query_column.rb', line 193

def owner
  [@pivoted_column.owner, @column.owner]
end

#select_nameObject



205
206
207
# File 'lib/chicago/schema/query_column.rb', line 205

def select_name
  :if.sql_function({@pivoted_column.select_name => @value}, @column.select_name, @unit)
end