Class: WWW::Mechanize::Form::Field
- Inherits:
-
Object
- Object
- WWW::Mechanize::Form::Field
- Defined in:
- lib/www/mechanize/form/field.rb
Overview
This class represents a field in a form. It handles the following input tags found in a form: text, password, hidden, int, textarea
To set the value of a field, just use the value method: field.value = “foo”
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(name, value) ⇒ Field
constructor
A new instance of Field.
- #query_value ⇒ Object
Constructor Details
#initialize(name, value) ⇒ Field
Returns a new instance of Field.
13 14 15 16 17 18 19 20 |
# File 'lib/www/mechanize/form/field.rb', line 13 def initialize(name, value) @name = Util.html_unescape(name) @value = if value.is_a? String Util.html_unescape(value) else value end end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
11 12 13 |
# File 'lib/www/mechanize/form/field.rb', line 11 def name @name end |
#value ⇒ Object
Returns the value of attribute value.
11 12 13 |
# File 'lib/www/mechanize/form/field.rb', line 11 def value @value end |
Instance Method Details
#query_value ⇒ Object
22 23 24 |
# File 'lib/www/mechanize/form/field.rb', line 22 def query_value [[@name, @value || '']] end |