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.

### Methods

accept_charset accept_language accept_language_with_weight http_variables http_vars inspect locales method_missing pretty_print to_instance_variables to_ivs to_s

### Constants

INTERESTING_HTTP_VARIABLES | = | (/USER|HOST|REQUEST|REMOTE|FORWARD|REFER|PATH|QUERY|VERSION|KEEP|CACHE/)
REQUEST_STRING_FORMAT | = | "#<%s params=%p cookies=%p env=%p>"

### Public Instance methods

accept_charset(default = 'UTF-8')
accept_language(string = env['HTTP_ACCEPT_LANGUAGE'])

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

accept_language_with_weight(string = env['HTTP_ACCEPT_LANGUAGE'])

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

http_variables()

Interesting HTTP variables from env

http_vars()

Alias for http_variables

inspect()

Alias for to_s

locales(string = env['HTTP_ACCEPT_LANGUAGE'])

Alias for accept_language

method_missing(meth, *args)

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

pretty_print(pp)

Pretty prints current action with parameters, cookies and enviroment variables.

to_instance_variables(*args)

Sets any arguments passed as @instance_variables for the current action.

Usage:

      request.params # => {'name' => 'manveru', 'q' => 'google', 'lang' => 'de'}
      request.to_ivs(:name, :q)
      @q    # => 'google'
      @name # => 'manveru'
      @lang # => nil

to_ivs(*args)

Alias for to_instance_variables

to_s()

[Validate]