Class: Cubicle::BucketizedDimension
- Defined in:
- lib/cubicle/bucketized_dimension.rb
Instance Attribute Summary collapse
-
#bucket_range ⇒ Object
Returns the value of attribute bucket_range.
-
#bump ⇒ Object
Returns the value of attribute bump.
-
#formatter ⇒ Object
Returns the value of attribute formatter.
-
#measure ⇒ Object
Returns the value of attribute measure.
-
#step ⇒ Object
Returns the value of attribute step.
Attributes inherited from Member
#alias_list, #condition, #expression_type, #field_name, #name, #options
Instance Method Summary collapse
- #expression ⇒ Object
-
#initialize(dimension_name, measure, bucket_range, options = {}, &block) ⇒ BucketizedDimension
constructor
A new instance of BucketizedDimension.
- #value_expression ⇒ Object
Methods inherited from Member
#included_in?, #matches, #to_js_keys, #to_js_value
Constructor Details
#initialize(dimension_name, measure, bucket_range, options = {}, &block) ⇒ BucketizedDimension
Returns a new instance of BucketizedDimension.
7 8 9 10 11 12 13 14 15 |
# File 'lib/cubicle/bucketized_dimension.rb', line 7 def initialize(dimension_name, measure, bucket_range, ={}, &block) super(dimension_name, ) @measure = measure @bucket_range = bucket_range @formatter = block @step = (:bucket_size, :step) || 1 @bump = (:range_start_bump, :bump) || 1 self.expression_type = :javascript end |
Instance Attribute Details
#bucket_range ⇒ Object
Returns the value of attribute bucket_range.
5 6 7 |
# File 'lib/cubicle/bucketized_dimension.rb', line 5 def bucket_range @bucket_range end |
#bump ⇒ Object
Returns the value of attribute bump.
5 6 7 |
# File 'lib/cubicle/bucketized_dimension.rb', line 5 def bump @bump end |
#formatter ⇒ Object
Returns the value of attribute formatter.
5 6 7 |
# File 'lib/cubicle/bucketized_dimension.rb', line 5 def formatter @formatter end |
#measure ⇒ Object
Returns the value of attribute measure.
5 6 7 |
# File 'lib/cubicle/bucketized_dimension.rb', line 5 def measure @measure end |
#step ⇒ Object
Returns the value of attribute step.
5 6 7 |
# File 'lib/cubicle/bucketized_dimension.rb', line 5 def step @step end |
Instance Method Details
#expression ⇒ Object
22 23 24 25 |
# File 'lib/cubicle/bucketized_dimension.rb', line 22 def expression generate_buckets @expression = "(function(val){if(val==null || isNaN(val))return null; #{@buckets.join(';')}})(#{value_expression})" end |
#value_expression ⇒ Object
17 18 19 20 |
# File 'lib/cubicle/bucketized_dimension.rb', line 17 def value_expression return measure.to_js_value if measure.respond_to?(:to_js_value) measure.to_s end |