Class: Hobix::WebApp::HTMLFormQuery
- Inherits:
-
Object
- Object
- Hobix::WebApp::HTMLFormQuery
- Defined in:
- lib/hobix/webapp/htmlform.rb
Overview
HTMLFormQuery represents a query submitted by HTML form.
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
- #each ⇒ Object
-
#initialize(*args) ⇒ HTMLFormQuery
constructor
A new instance of HTMLFormQuery.
- #keys ⇒ Object
- #lookup_all(key) ⇒ Object
Constructor Details
#initialize(*args) ⇒ HTMLFormQuery
Returns a new instance of HTMLFormQuery.
73 74 75 76 77 78 79 |
# File 'lib/hobix/webapp/htmlform.rb', line 73 def initialize(*args) @param = [] HTMLFormQuery.each_string_key_pair(args) {|key, val| @param << [key, val] } @param.freeze end |
Class Method Details
.each_string_key_pair(arg, &block) ⇒ Object
:nodoc:
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/hobix/webapp/htmlform.rb', line 54 def HTMLFormQuery.each_string_key_pair(arg, &block) # :nodoc: if arg.respond_to? :to_ary arg = arg.to_ary if arg.length == 2 && arg.first.respond_to?(:to_str) yield WebApp.make_frozen_string(arg.first), arg.last else arg.each {|elt| HTMLFormQuery.each_string_key_pair(elt, &block) } end elsif arg.respond_to? :to_pair arg.each_pair {|key, val| yield WebApp.make_frozen_string(key), val } else raise ArgumentError, "non-pairs argument: #{arg.inspect}" end end |
Instance Method Details
#[](key) ⇒ Object
87 88 89 90 91 92 |
# File 'lib/hobix/webapp/htmlform.rb', line 87 def [](key) if pair = @param.assoc(key) return pair.last.dup end return nil end |
#each ⇒ Object
81 82 83 84 85 |
# File 'lib/hobix/webapp/htmlform.rb', line 81 def each @param.each {|key, val| yield key.dup, val.dup } end |
#keys ⇒ Object
102 103 104 |
# File 'lib/hobix/webapp/htmlform.rb', line 102 def keys @param.map {|key, val| key }.uniq end |
#lookup_all(key) ⇒ Object
94 95 96 97 98 99 100 |
# File 'lib/hobix/webapp/htmlform.rb', line 94 def lookup_all(key) result = [] @param.each {|k, val| result << val if k == key } return result end |