Class: Mechanize::Form::RadioButton
- Defined in:
- lib/mechanize/form/radio_button.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
(also: #checked?)
Returns the value of attribute checked.
-
#form ⇒ Object
readonly
Returns the value of attribute form.
Attributes inherited from Field
#index, #name, #node, #raw_value, #type, #value
Instance Method Summary collapse
-
#==(other) ⇒ Object
(also: #eql?)
:nodoc:.
- #[](key) ⇒ Object
- #check ⇒ Object
- #click ⇒ Object
-
#hash ⇒ Object
:nodoc:.
-
#initialize(node, form) ⇒ RadioButton
constructor
A new instance of RadioButton.
- #label ⇒ Object
-
#pretty_print_instance_variables ⇒ Object
:nodoc:.
- #text ⇒ Object
- #uncheck ⇒ Object
Methods inherited from Field
#<=>, #dom_class, #dom_id, #inspect, #query_value
Constructor Details
#initialize(node, form) ⇒ RadioButton
Returns a new instance of RadioButton.
9 10 11 12 13 |
# File 'lib/mechanize/form/radio_button.rb', line 9 def initialize node, form @checked = !!node['checked'] @form = form super(node) end |
Instance Attribute Details
#checked ⇒ Object Also known as: checked?
Returns the value of attribute checked.
6 7 8 |
# File 'lib/mechanize/form/radio_button.rb', line 6 def checked @checked end |
#form ⇒ Object (readonly)
Returns the value of attribute form.
7 8 9 |
# File 'lib/mechanize/form/radio_button.rb', line 7 def form @form end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
:nodoc:
15 16 17 18 19 20 |
# File 'lib/mechanize/form/radio_button.rb', line 15 def == other # :nodoc: self.class === other and other.form == @form and other.name == @name and other.value == @value end |
#[](key) ⇒ Object
51 52 53 |
# File 'lib/mechanize/form/radio_button.rb', line 51 def [](key) @node[key] end |
#check ⇒ Object
24 25 26 27 |
# File 'lib/mechanize/form/radio_button.rb', line 24 def check uncheck_peers @checked = true end |
#click ⇒ Object
35 36 37 |
# File 'lib/mechanize/form/radio_button.rb', line 35 def click checked ? uncheck : check end |
#hash ⇒ Object
:nodoc:
39 40 41 |
# File 'lib/mechanize/form/radio_button.rb', line 39 def hash # :nodoc: @form.hash ^ @name.hash ^ @value.hash end |
#label ⇒ Object
43 44 45 |
# File 'lib/mechanize/form/radio_button.rb', line 43 def label (id = self['id']) && @form.page.labels_hash[id] || nil end |
#pretty_print_instance_variables ⇒ Object
:nodoc:
55 56 57 |
# File 'lib/mechanize/form/radio_button.rb', line 55 def pretty_print_instance_variables # :nodoc: [:@checked, :@name, :@value] end |
#text ⇒ Object
47 48 49 |
# File 'lib/mechanize/form/radio_button.rb', line 47 def text label.text rescue nil end |
#uncheck ⇒ Object
31 32 33 |
# File 'lib/mechanize/form/radio_button.rb', line 31 def uncheck @checked = false end |