Class: Rack::ICU4X::Locale::Detector::Query
- Inherits:
-
Object
- Object
- Rack::ICU4X::Locale::Detector::Query
- Defined in:
- lib/rack/icu4x/locale/detector/query.rb
Overview
Detects locale from a query string parameter.
Instance Method Summary collapse
-
#call(env) ⇒ String?
Locale from query parameter, or nil if not present.
-
#initialize(param = DEFAULT_PARAM) ⇒ Query
constructor
A new instance of Query.
Constructor Details
#initialize(param = DEFAULT_PARAM) ⇒ Query
Returns a new instance of Query.
23 24 25 |
# File 'lib/rack/icu4x/locale/detector/query.rb', line 23 def initialize(param=DEFAULT_PARAM) @param = param end |
Instance Method Details
#call(env) ⇒ String?
Returns Locale from query parameter, or nil if not present.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rack/icu4x/locale/detector/query.rb', line 29 def call(env) query_string = env["QUERY_STRING"] return nil if query_string.nil? || query_string.empty? params = ::Rack::Utils.parse_query(query_string) locale = params[@param] return nil if locale.nil? || locale.empty? locale end |