Class: XRB::Query::Delegate
- Inherits:
-
Object
- Object
- XRB::Query::Delegate
- Defined in:
- lib/xrb/query.rb
Instance Method Summary collapse
- #append ⇒ Object
- #assign(value, encoded) ⇒ Object
- #index(key) ⇒ Object
-
#initialize(top = {}) ⇒ Delegate
constructor
A new instance of Delegate.
- #integer(key) ⇒ Object
- #pair ⇒ Object
- #string(key, encoded) ⇒ Object
Constructor Details
#initialize(top = {}) ⇒ Delegate
Returns a new instance of Delegate.
20 21 22 23 24 25 |
# File 'lib/xrb/query.rb', line 20 def initialize(top = {}) @top = top @current = @top @index = nil end |
Instance Method Details
#append ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/xrb/query.rb', line 49 def append if @index @current = @current.fetch(@index) do @current[@index] = [] end end @index = @current.size end |
#assign(value, encoded) ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/xrb/query.rb', line 59 def assign(value, encoded) if encoded value = ::URI.decode_www_form_component(value) end @current[@index] = value @current = @top @index = nil end |
#index(key) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/xrb/query.rb', line 39 def index(key) if @index @current = @current.fetch(@index) do @current[@index] = {} end end @index = key end |
#integer(key) ⇒ Object
35 36 37 |
# File 'lib/xrb/query.rb', line 35 def integer(key) index(key.to_i) end |
#pair ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/xrb/query.rb', line 70 def pair if @index @current[@index] = true end @current = @top @index = nil end |
#string(key, encoded) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/xrb/query.rb', line 27 def string(key, encoded) if encoded key = ::URI.decode_www_form_component(key) end index(key.to_sym) end |