Class: Casino::Query
- Inherits:
-
Object
- Object
- Casino::Query
- Defined in:
- lib/casino/query.rb
Instance Attribute Summary collapse
-
#conditions ⇒ Object
Returns the value of attribute conditions.
-
#criteria ⇒ Object
Returns the value of attribute criteria.
-
#label ⇒ Object
Returns the value of attribute label.
Instance Method Summary collapse
- #build_conditions(dimension) ⇒ Object
-
#initialize(label, conditions, *criteria) ⇒ Query
constructor
A new instance of Query.
- #merge(dimension) ⇒ Object
Constructor Details
#initialize(label, conditions, *criteria) ⇒ Query
Returns a new instance of Query.
5 6 7 8 9 |
# File 'lib/casino/query.rb', line 5 def initialize(label, conditions, *criteria) self.label = label self.conditions = conditions self.criteria = criteria end |
Instance Attribute Details
#conditions ⇒ Object
Returns the value of attribute conditions.
3 4 5 |
# File 'lib/casino/query.rb', line 3 def conditions @conditions end |
#criteria ⇒ Object
Returns the value of attribute criteria.
3 4 5 |
# File 'lib/casino/query.rb', line 3 def criteria @criteria end |
#label ⇒ Object
Returns the value of attribute label.
3 4 5 |
# File 'lib/casino/query.rb', line 3 def label @label end |
Instance Method Details
#build_conditions(dimension) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/casino/query.rb', line 15 def build_conditions(dimension) criteria.map do |condition| [ dimension.approach[:operator], { dimension.field => condition } ] end end |
#merge(dimension) ⇒ Object
11 12 13 |
# File 'lib/casino/query.rb', line 11 def merge(dimension) self.class.new(label, build_conditions(dimension), *criteria) end |