Class: ChambaSearchMx::UrlFormatter
- Inherits:
-
Object
- Object
- ChambaSearchMx::UrlFormatter
- Defined in:
- lib/chamba_search_mx/url_formatter.rb
Overview
it formats urls base on hash options
Instance Method Summary collapse
- #format(query, *options) ⇒ Object
-
#initialize(opts = {}) ⇒ UrlFormatter
constructor
A new instance of UrlFormatter.
Constructor Details
#initialize(opts = {}) ⇒ UrlFormatter
8 9 10 11 12 |
# File 'lib/chamba_search_mx/url_formatter.rb', line 8 def initialize(opts = {}) @locations = opts[:locations] || ChambaSearchMx::LOCATIONS @salaries = opts[:salaries] || ChambaSearchMx::SALARIES @days = opts[:days] || ChambaSearchMx::DAYS end |
Instance Method Details
#format(query, *options) ⇒ Object
17 18 19 20 21 |
# File 'lib/chamba_search_mx/url_formatter.rb', line 17 def format(query, *) @query = query = .inject({}) { |acc, elem| acc.merge! elem } "/#{location}#{salary}#{days}/#{query_slug}" end |