Class: WWMD::Inputs

Inherits:
Object
  • Object
show all
Defined in:
lib/wwmd/page/inputs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#elemsObject

Returns the value of attribute elems.



3
4
5
# File 'lib/wwmd/page/inputs.rb', line 3

def elems
  @elems
end

Instance Method Details

#formObject

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

#paramsObject

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

#setObject

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

#showObject



12
13
14
# File 'lib/wwmd/page/inputs.rb', line 12

def show
  putx @elems
end