Class: Mechanize::Form::RadioButton
- Inherits:
-
Field
- Object
- Field
- Mechanize::Form::RadioButton
show all
- 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.
Instance Attribute Summary collapse
Attributes inherited from Field
#name, #node, #type, #value
Instance Method Summary
collapse
Methods inherited from Field
#<=>, #dom_class, #dom_id, #query_value
Constructor Details
#initialize(node, form) ⇒ RadioButton
Returns a new instance of RadioButton.
8
9
10
11
12
|
# File 'lib/mechanize/form/radio_button.rb', line 8
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
|
Instance Method Details
#[](key) ⇒ Object
37
38
39
|
# File 'lib/mechanize/form/radio_button.rb', line 37
def [](key)
@node[key]
end
|
#check ⇒ Object
14
15
16
17
|
# File 'lib/mechanize/form/radio_button.rb', line 14
def check
uncheck_peers
@checked = true
end
|
#click ⇒ Object
25
26
27
|
# File 'lib/mechanize/form/radio_button.rb', line 25
def click
checked ? uncheck : check
end
|
#label ⇒ Object
29
30
31
|
# File 'lib/mechanize/form/radio_button.rb', line 29
def label
(id = self['id']) && @form.page.labels_hash[id] || nil
end
|
#pretty_print_instance_variables ⇒ Object
41
42
43
|
# File 'lib/mechanize/form/radio_button.rb', line 41
def pretty_print_instance_variables [:@checked, :@name, :@value]
end
|
#text ⇒ Object
33
34
35
|
# File 'lib/mechanize/form/radio_button.rb', line 33
def text
label.text rescue nil
end
|
#uncheck ⇒ Object
21
22
23
|
# File 'lib/mechanize/form/radio_button.rb', line 21
def uncheck
@checked = false
end
|