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.
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 |
Instance Method Details
#keyword_to_url ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/query.rb', line 18 def keyword_to_url if keyword == "nyc" "" else "/#{keyword}" end end |
#parse(query_string) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/query.rb', line 5 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 |
#valid_query? ⇒ Boolean
14 15 16 |
# File 'lib/query.rb', line 14 def valid_query? Runner.keywords.keys.include?(self.keyword) && self.search_query.is_a?(String) && self.max_price.is_a?(Integer) && self.min_price.is_a?(Integer) end |