Class: Cubicle::Difference
- Inherits:
-
CalculatedMeasure
- Object
- Member
- Measure
- CalculatedMeasure
- Cubicle::Difference
- Defined in:
- lib/cubicle/difference.rb
Instance Attribute Summary collapse
-
#left ⇒ Object
readonly
Returns the value of attribute left.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
Attributes inherited from Measure
Attributes inherited from Member
#alias_list, #condition, #expression, #expression_type, #field_name, #name, #options
Instance Method Summary collapse
- #aggregate(values) ⇒ Object
- #depends_on ⇒ Object
- #finalize_aggregation(aggregation) ⇒ Object
-
#initialize(member_name, left, right, opts = {}) ⇒ Difference
constructor
A new instance of Difference.
Methods inherited from CalculatedMeasure
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
#left ⇒ Object (readonly)
Returns the value of attribute left.
4 5 6 |
# File 'lib/cubicle/difference.rb', line 4 def left @left end |
#right ⇒ Object (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_on ⇒ Object
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 |