Class: Cubicle::Difference

Inherits:
CalculatedMeasure show all
Defined in:
lib/cubicle/difference.rb

Instance Attribute Summary collapse

Attributes inherited from Measure

#aggregation_method

Attributes inherited from Member

#alias_list, #condition, #expression, #expression_type, #field_name, #name, #options

Instance Method Summary collapse

Methods inherited from CalculatedMeasure

#to_js_keys

Methods inherited from Measure

#default_aggregation_method, #distinct_count?, #expression

Methods inherited from Member

#included_in?, #matches, #to_js_keys, #to_js_value

Constructor Details

#initialize(member_name, left, right, opts = {}) ⇒ Difference

Returns a new instance of Difference.



5
6
7
8
9
# File 'lib/cubicle/difference.rb', line 5

def initialize(member_name,left,right,opts={})
  @left, @right = left, right
  #opts[:expression]="(value.#{denominator} > 0 && value.#{numerator} ? value.#{numerator}/value.#{denominator} : 0)"
  super(member_name,opts)
end

Instance Attribute Details

#leftObject (readonly)

Returns the value of attribute left.



4
5
6
# File 'lib/cubicle/difference.rb', line 4

def left
  @left
end

#rightObject (readonly)

Returns the value of attribute right.



4
5
6
# File 'lib/cubicle/difference.rb', line 4

def right
  @right
end

Instance Method Details

#aggregate(values) ⇒ Object



11
12
13
# File 'lib/cubicle/difference.rb', line 11

def aggregate(values)
  0
end

#depends_onObject



22
23
24
# File 'lib/cubicle/difference.rb', line 22

def depends_on
  [left,right]
end

#finalize_aggregation(aggregation) ⇒ Object



15
16
17
18
19
20
# File 'lib/cubicle/difference.rb', line 15

def finalize_aggregation(aggregation)
  l = aggregation[left].to_f
  r = aggregation[right].to_f

  aggregation[name] = l - r
end