Class WWW::Mechanize::Option
In: lib/mechanize/form_elements.rb
Parent: Object
Mechanize\n[lib/mechanize.rb\nlib/mechanize/cookie.rb\nlib/mechanize/errors.rb\nlib/mechanize/form.rb\nlib/mechanize/form_elements.rb\nlib/mechanize/history.rb\nlib/mechanize/list.rb\nlib/mechanize/page.rb\nlib/mechanize/page_elements.rb\nlib/mechanize/pluggable_parsers.rb] lib/mechanize.rb WWW dot/m_19_0.png

This class contains option an option found within SelectList. A SelectList can have many Option classes associated with it. An option can be selected by calling Option#tick, or Option#click. For example, select the first option in a list:

 select_list.first.tick

Methods

click   new   select   tick   unselect   unselect_peers   untick  

External Aliases

value -> to_s
selected -> selected?

Attributes

select_list  [R] 
selected  [R] 
text  [R] 
value  [R] 

Public Class methods

[Source]

     # File lib/mechanize/form_elements.rb, line 219
219:     def initialize(node, select_list)
220:       @text     = node.inner_text
221:       @value    = Util.html_unescape(node['value'])
222:       @selected = node.has_attribute? 'selected'
223:       @select_list = select_list # The select list this option belongs to
224:     end

Public Instance methods

Toggle the selection value of this option

[Source]

     # File lib/mechanize/form_elements.rb, line 241
241:     def click
242:       unselect_peers
243:       @selected = !@selected
244:     end

Select this option

[Source]

     # File lib/mechanize/form_elements.rb, line 227
227:     def select
228:       unselect_peers
229:       @selected = true
230:     end
tick()

Alias for select

Unselect this option

[Source]

     # File lib/mechanize/form_elements.rb, line 233
233:     def unselect
234:       @selected = false
235:     end
untick()

Alias for unselect

Private Instance methods

[Source]

     # File lib/mechanize/form_elements.rb, line 247
247:     def unselect_peers
248:       if @select_list.instance_of? WWW::Mechanize::SelectList
249:         @select_list.select_none
250:       end
251:     end

[Validate]