Class | Ramaze::Request |
In: |
lib/ramaze/request.rb
|
Parent: | Innate::Request |
The purpose of this class is to act as a simple wrapper for Rack::Request and provide some convinient methods for our own use.
INTERESTING_HTTP_VARIABLES | = | (/USER|HOST|REQUEST|REMOTE|FORWARD|REFER|PATH|QUERY|VERSION|KEEP|CACHE/) |
REQUEST_STRING_FORMAT | = | "#<%s params=%p cookies=%p env=%p>" |
Try to find out which languages the client would like to have and sort them by weight, (most wanted first).
Returns and array of locales from env[‘HTTP_ACCEPT_LANGUAGE]. e.g. ["fi", "en", "ja", "fr", "de", "es", "it", "nl", "sv"]
Usage:
request.accept_language # => ['en-us', 'en', 'de-at', 'de']
@param [String to_s] string the value of HTTP_ACCEPT_LANGUAGE @return [Array] list of locales @see Request#accept_language_with_weight @author manveru
Transform the HTTP_ACCEPT_LANGUAGE header into an Array with:
[[lang, weight], [lang, weight], ...]
This algorithm was taken and improved from the locales library.
Usage:
request.accept_language_with_weight # => [["en-us", 1.0], ["en", 0.8], ["de-at", 0.5], ["de", 0.3]]
@param [String to_s] string the value of HTTP_ACCEPT_LANGUAGE @return [Array] array of [lang, weight] arrays @see Request#accept_language @author manveru
you can access the original @request via this method_missing, first it tries to match your method with any of the HTTP parameters then, in case that fails, it will relay to @request