Class: Cdek::CitySuggestions
- Inherits:
-
Object
- Object
- Cdek::CitySuggestions
- Defined in:
- lib/cdek/city_suggestions.rb
Overview
Builds normalized city suggestions for host application autocomplete UIs.
Constant Summary collapse
- DEFAULT_COUNTRY_CODE =
"RU"- DEFAULT_LIMIT =
10- MIN_QUERY_LENGTH =
2
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(query, client: Cdek.client, country_code: DEFAULT_COUNTRY_CODE, limit: DEFAULT_LIMIT) ⇒ CitySuggestions
constructor
A new instance of CitySuggestions.
Constructor Details
#initialize(query, client: Cdek.client, country_code: DEFAULT_COUNTRY_CODE, limit: DEFAULT_LIMIT) ⇒ CitySuggestions
Returns a new instance of CitySuggestions.
16 17 18 19 20 21 |
# File 'lib/cdek/city_suggestions.rb', line 16 def initialize(query, client: Cdek.client, country_code: DEFAULT_COUNTRY_CODE, limit: DEFAULT_LIMIT) @query = query @client = client @country_code = country_code @limit = limit end |
Class Method Details
.call(query, **options) ⇒ Object
11 12 13 |
# File 'lib/cdek/city_suggestions.rb', line 11 def call(query, **) new(query, **).call end |
Instance Method Details
#call ⇒ Object
23 24 25 |
# File 'lib/cdek/city_suggestions.rb', line 23 def call normalized_query.length < MIN_QUERY_LENGTH ? [] : normalized_suggestions end |