class Mechanize::Form::RadioButton

This class represents a radio button found in a Form. To activate the RadioButton in the Form, set the checked method to true.

Attributes

checked[RW]
checked?[RW]
form[R]

Public Class Methods

new(node, form) click to toggle source
Calls superclass method Mechanize::Form::Field.new
# File lib/mechanize/form/radio_button.rb, line 9
def initialize node, form
  @checked = !!node['checked']
  @form    = form
  super(node)
end

Public Instance Methods

[](key) click to toggle source
# File lib/mechanize/form/radio_button.rb, line 51
def [](key)
  @node[key]
end
check() click to toggle source
# File lib/mechanize/form/radio_button.rb, line 24
def check
  uncheck_peers
  @checked = true
end
click() click to toggle source
# File lib/mechanize/form/radio_button.rb, line 35
def click
  checked ? uncheck : check
end
label() click to toggle source
# File lib/mechanize/form/radio_button.rb, line 43
def label
  (id = self['id']) && @form.page.labels_hash[id] || nil
end
text() click to toggle source
# File lib/mechanize/form/radio_button.rb, line 47
def text
  label.text rescue nil
end
uncheck() click to toggle source
# File lib/mechanize/form/radio_button.rb, line 31
def uncheck
  @checked = false
end