Class: WWMD::Form

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

Overview

original author of hpricot_form

Chew Choon Keat <choonkeat at gmail>
http://blog.yanime.org/
19 July 2006

updated by mtracy at matasano.com for use with Nokogiri and WWMD

Direct Known Subclasses

Field

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(doc) ⇒ Form

Returns a new instance of Form.



17
18
19
20
# File 'lib/wwmd/page/form.rb', line 17

def initialize(doc)
  @hdoc = doc
  @formtag = @hdoc.search("//form")
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object



22
23
24
# File 'lib/wwmd/page/form.rb', line 22

def method_missing(*args)
  hdoc.send(*args)
end

Instance Attribute Details

#fieldsObject

Returns the value of attribute fields.



14
15
16
# File 'lib/wwmd/page/form.rb', line 14

def fields
  @fields
end

#formtagObject

Returns the value of attribute formtag.



15
16
17
# File 'lib/wwmd/page/form.rb', line 15

def formtag
  @formtag
end

#hdocObject

Returns the value of attribute hdoc.



13
14
15
# File 'lib/wwmd/page/form.rb', line 13

def hdoc
  @hdoc
end

Instance Method Details

#actionObject



39
40
41
# File 'lib/wwmd/page/form.rb', line 39

def action
  return self.get_attribute("action")
end

#field_namesObject



35
36
37
# File 'lib/wwmd/page/form.rb', line 35

def field_names
  fields.map { |x| x.get_attribute("name") }
end

#old_fieldsObject

Returns the value of attribute fields.



26
27
28
# File 'lib/wwmd/page/form.rb', line 26

def fields
  @fields
end

#reportObject Also known as: show



92
93
94
95
96
97
# File 'lib/wwmd/page/irb_helpers.rb', line 92

def report
  return nil if not WWMD::console
  puts "action = #{self.action}"
  self.fields.each { |field| puts field.to_text }
  return nil
end

#typeObject



43
44
45
# File 'lib/wwmd/page/form.rb', line 43

def type
  return self.get_attribute("method")
end