Class: Query
- Inherits:
-
Object
- Object
- Query
- Defined in:
- lib/query.rb
Instance Attribute Summary collapse
-
#keyword ⇒ Object
Returns the value of attribute keyword.
-
#max_price ⇒ Object
Returns the value of attribute max_price.
-
#min_price ⇒ Object
Returns the value of attribute min_price.
-
#search_query ⇒ Object
Returns the value of attribute search_query.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#keyword ⇒ Object
Returns the value of attribute keyword.
3 4 5 |
# File 'lib/query.rb', line 3 def keyword @keyword end |
#max_price ⇒ Object
Returns the value of attribute max_price.
3 4 5 |
# File 'lib/query.rb', line 3 def max_price @max_price end |
#min_price ⇒ Object
Returns the value of attribute min_price.
3 4 5 |
# File 'lib/query.rb', line 3 def min_price @min_price end |
#search_query ⇒ Object
Returns the value of attribute search_query.
3 4 5 |
# File 'lib/query.rb', line 3 def search_query @search_query end |
Class Method Details
.keywords ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/query.rb', line 5 def self.keywords { "mnh" => "Manhattan", "brk" => "Brooklyn", "que" => "Queens", "brx" => "The Bronx", "stn" => "Staten Island", "jsy" => "New Jersey", "lgi" => "Long Island", "wch" => "Westchester", "fct" => "Fairfield", "nyc" => "New York City", } end |
Instance Method Details
#keyword_to_url ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/query.rb', line 33 def keyword_to_url if keyword == "nyc" "" else "/#{keyword}" end end |
#parse(query_string) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/query.rb', line 20 def parse(query_string) query_array = query_string.split(" ") self.keyword = query_array.shift self.max_price = query_array.pop.to_i self.min_price = query_array.pop.to_i self.search_query = query_array.join(" ") return self end |