Class: ActiveRecordCalculator::Column

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

Instance Method Summary collapse

Constructor Details

#initialize(name, as) ⇒ Column

Returns a new instance of Column.



4
5
6
7
# File 'lib/active_record_calculator/column.rb', line 4

def initialize(name, as)
  @name = name
  @as = as
end

Instance Method Details

#alias_nameObject



17
18
19
# File 'lib/active_record_calculator/column.rb', line 17

def alias_name
  @as.to_s
end

#build_selectObject



9
10
11
# File 'lib/active_record_calculator/column.rb', line 9

def build_select
  "#{@name} AS #{@as || @name}"
end

#inspectObject



13
14
15
# File 'lib/active_record_calculator/column.rb', line 13

def inspect
  @name.to_s
end