Module: Rack::ICU4X::Locale::Detector
- Defined in:
- lib/rack/icu4x/locale/detector.rb,
lib/rack/icu4x/locale/detector/query.rb,
lib/rack/icu4x/locale/detector/cookie.rb,
lib/rack/icu4x/locale/detector/header.rb
Overview
Factory module for building detector instances from various specification formats.
Detectors are responsible for extracting locale preferences from the Rack environment. All detectors respond to ‘#call(env)` and return:
-
String: single locale (e.g., “ja”)
-
Array<String>: multiple locales in preference order (e.g., [“ja”, “en”])
-
nil: no locale detected
Defined Under Namespace
Classes: Cookie, Header, InvalidSpecificationError, Query
Class Method Summary collapse
-
.build(spec) ⇒ #call
Build a detector from various specification formats.
Class Method Details
.build(spec) ⇒ #call
Build a detector from various specification formats.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rack/icu4x/locale/detector.rb', line 29 def self.build(spec) case spec when Symbol then build_from_symbol(spec) when Hash then build_from_hash(spec) when Proc then spec else validate_callable!(spec) spec end end |