Class: Mechanize::Form::RadioButton
- Defined in:
- lib/mechanize/form/radio_button.rb,
lib/mechanize/inspect.rb
Overview
This class represents a radio button found in a Form. To activate the RadioButton in the Form, set the checked method to true.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#checked ⇒ Object
Returns the value of attribute checked.
Attributes inherited from Field
Instance Method Summary collapse
- #[](key) ⇒ Object
- #check ⇒ Object
- #click ⇒ Object
-
#initialize(name, value, checked, form, node) ⇒ RadioButton
constructor
A new instance of RadioButton.
- #label ⇒ Object
- #pretty_print_instance_variables ⇒ Object
- #text ⇒ Object
- #uncheck ⇒ Object
Methods inherited from Field
Constructor Details
#initialize(name, value, checked, form, node) ⇒ RadioButton
Returns a new instance of RadioButton.
8 9 10 11 12 13 |
# File 'lib/mechanize/form/radio_button.rb', line 8 def initialize(name, value, checked, form, node) @checked = checked @form = form @node = node super(name, value) end |
Instance Attribute Details
#checked ⇒ Object
Returns the value of attribute checked.
6 7 8 |
# File 'lib/mechanize/form/radio_button.rb', line 6 def checked @checked end |
Instance Method Details
#[](key) ⇒ Object
36 37 38 |
# File 'lib/mechanize/form/radio_button.rb', line 36 def [](key) @node[key] end |
#check ⇒ Object
15 16 17 18 |
# File 'lib/mechanize/form/radio_button.rb', line 15 def check uncheck_peers @checked = true end |
#click ⇒ Object
24 25 26 |
# File 'lib/mechanize/form/radio_button.rb', line 24 def click checked ? uncheck : check end |
#label ⇒ Object
28 29 30 |
# File 'lib/mechanize/form/radio_button.rb', line 28 def label (id = self['id']) && @form.page.labels_hash[id] || nil end |
#pretty_print_instance_variables ⇒ Object
82 83 84 |
# File 'lib/mechanize/inspect.rb', line 82 def pretty_print_instance_variables [:@checked, :@name, :@value] end |
#text ⇒ Object
32 33 34 |
# File 'lib/mechanize/form/radio_button.rb', line 32 def text label.text rescue nil end |
#uncheck ⇒ Object
20 21 22 |
# File 'lib/mechanize/form/radio_button.rb', line 20 def uncheck @checked = false end |