Class: Chicago::Schema::PivotedColumn
Instance Method Summary
collapse
Methods inherited from QueryColumn
column, #filter_dataset, #method_missing, #qualified_label
Constructor Details
#initialize(column, pivoted_by, index, value, unit = 0) ⇒ PivotedColumn
Returns a new instance of PivotedColumn.
197
198
199
200
201
202
203
|
# File 'lib/chicago/schema/query_column.rb', line 197
def initialize(column, pivoted_by, index, value, unit=0)
super column
@pivoted_column = pivoted_by
@index = index
@value = value
@unit = unit
end
|
Instance Method Details
#calculate(operation) ⇒ Object
205
206
207
|
# File 'lib/chicago/schema/query_column.rb', line 205
def calculate(operation)
CalculatedColumn.make(operation, self)
end
|
#column_alias ⇒ Object
217
218
219
|
# File 'lib/chicago/schema/query_column.rb', line 217
def column_alias
"#{@column.column_alias}:#{@pivoted_column.column_alias}.#{@index}".to_sym
end
|
#count_name ⇒ Object
229
230
231
|
# File 'lib/chicago/schema/query_column.rb', line 229
def count_name
Sequel.case([[{@pivoted_column.select_name => @value}, @column.count_name]], @unit)
end
|
#group_name ⇒ Object
221
222
223
|
# File 'lib/chicago/schema/query_column.rb', line 221
def group_name
nil
end
|
#label ⇒ Object
209
210
211
|
# File 'lib/chicago/schema/query_column.rb', line 209
def label
[@column.label, @value]
end
|
#owner ⇒ Object
213
214
215
|
# File 'lib/chicago/schema/query_column.rb', line 213
def owner
[@pivoted_column.owner, @column.owner]
end
|
#select_name ⇒ Object
225
226
227
|
# File 'lib/chicago/schema/query_column.rb', line 225
def select_name
Sequel.case([[{@pivoted_column.select_name => @value}, @column.select_name]], @unit)
end
|