Class: FuzzyRealty::Query
- Inherits:
-
Object
- Object
- FuzzyRealty::Query
- Defined in:
- lib/classes.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Class Method Summary collapse
-
.random ⇒ Object
Create a random query for testing.
Instance Method Summary collapse
-
#<<(param) ⇒ Object
Allows formation of Query by ‘popping’ parameters onto it.
-
#initialize(params = []) ⇒ Query
constructor
A new instance of Query.
Constructor Details
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
3 4 5 |
# File 'lib/classes.rb', line 3 def params @params end |
Class Method Details
.random ⇒ Object
Create a random query for testing
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/classes.rb', line 19 def self.random query = Query.new query << Parameter.new(:price, 20_000 + rand(250_000), [true,false][rand(1)]) query << Parameter.new(:sqft, 300 + rand(2000), [true,false][rand(1)]) query << Parameter.new(:location, %W{A B C D}[rand(4)], [true,false][rand(1)]) query << Parameter.new( :style, %W{Bungalow Bi-level Split-level Two-story Condominium}[rand(5)], [true,false][rand(1)]) query end |
Instance Method Details
#<<(param) ⇒ Object
Allows formation of Query by ‘popping’ parameters onto it
11 12 13 14 15 16 |
# File 'lib/classes.rb', line 11 def << (param) if !param.is_a?(Parameter) raise "Attempting to add non-Parameter to Query" end @params << param end |