Class: WWMD::Field

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

Instance Attribute Summary

Attributes inherited from Form

#fields, #formtag, #hdoc

Instance Method Summary collapse

Methods inherited from Form

#action, #field_names, #initialize, #method_missing, #old_fields, #report, #type

Constructor Details

This class inherits a constructor from WWMD::Form

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class WWMD::Form

Instance Method Details

#_valueObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/wwmd/page/form.rb', line 65

def _value
  # selection (array)
  if PARSER == :nokogiri
    ret = hdoc.search(".//option[@selected]").collect { |x| x.get_attribute("value") }
  else
    ret = hdoc.search("//option[@selected]").collect { |x| x.get_attribute("value") }
  end
  case ret.size
  when 0
    if name == "textarea"
      if PARSER == :nokogiri
        hdoc.text
      else
        hdoc.innerHTML
      end
    else
      hdoc.get_attribute("value") if (hdoc.get_attribute("checked") || !hdoc.get_attribute("type") =~ /radio|checkbox/)
    end
  when 1
    ret.first
  else
    ret
  end
end

#fnameObject



57
58
59
# File 'lib/wwmd/page/form.rb', line 57

def fname
  self.get_attribute('name')
end

#ftypeObject



61
62
63
# File 'lib/wwmd/page/form.rb', line 61

def ftype
  self.get_attribute('type')
end

#to_arrObject



90
91
92
# File 'lib/wwmd/page/form.rb', line 90

def to_arr
  return [self.name, self.ftype, self.fname, self.fvalue]
end

#to_textObject



94
95
96
# File 'lib/wwmd/page/form.rb', line 94

def to_text
  return "tag=#{self.name} type=#{self.ftype} name=#{self.fname} value=#{self.fvalue}"
end

#valueObject Also known as: get_value, fvalue



50
51
52
# File 'lib/wwmd/page/form.rb', line 50

def value
  self._value.nil? ? self.get_attribute("value") : self._value
end