Class: WWMD::Inputs
- Inherits:
-
Object
- Object
- WWMD::Inputs
- Defined in:
- lib/wwmd/page/inputs.rb
Instance Attribute Summary collapse
-
#elems ⇒ Object
Returns the value of attribute elems.
Instance Method Summary collapse
-
#form ⇒ Object
return: FormArray containing all page inputs.
- #get(attr = nil) ⇒ Object
-
#initialize(*args) ⇒ Inputs
constructor
A new instance of Inputs.
-
#params ⇒ Object
return: FormArray containing get params.
-
#set ⇒ Object
call me from Page.set_data.
- #show ⇒ Object
Constructor Details
#initialize(*args) ⇒ Inputs
Returns a new instance of Inputs.
8 9 10 |
# File 'lib/wwmd/page/inputs.rb', line 8 def initialize(*args) @cobj = args.shift end |
Instance Attribute Details
#elems ⇒ Object
Returns the value of attribute elems.
3 4 5 |
# File 'lib/wwmd/page/inputs.rb', line 3 def elems @elems end |
Instance Method Details
#form ⇒ Object
return: FormArray containing all page inputs
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/wwmd/page/inputs.rb', line 27 def form ret = {} @elems.map do |x| name = x['name'] id = x['id'] next if (name.nil? && id.nil?) value = x['value'] type = x['type'] ret[name] = value ret[id] = value if ((id || name) != name) end return FormArray.new(ret) end |
#get(attr = nil) ⇒ Object
21 22 23 |
# File 'lib/wwmd/page/inputs.rb', line 21 def get(attr=nil) @elems.map { |x| x[attr] }.reject { |y| y.nil? } end |
#params ⇒ Object
return: FormArray containing get params
43 44 45 |
# File 'lib/wwmd/page/inputs.rb', line 43 def params return FormArray.new(@cobj.cur.clop.to_form) end |
#set ⇒ Object
call me from Page.set_data
17 18 19 |
# File 'lib/wwmd/page/inputs.rb', line 17 def set @elems = [@cobj.search("//input").map,@cobj.search("//select").map].flatten end |
#show ⇒ Object
12 13 14 |
# File 'lib/wwmd/page/inputs.rb', line 12 def show putx @elems end |