Class: WWW::Mechanize::Form::RadioButton

Inherits:
Field
  • Object
show all
Defined in:
lib/www/mechanize/form/radio_button.rb,
lib/www/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

CheckBox

Instance Attribute Summary collapse

Attributes inherited from Field

#name, #value

Instance Method Summary collapse

Methods inherited from Field

#query_value

Constructor Details

#initialize(name, value, checked, form) ⇒ RadioButton

Returns a new instance of RadioButton.



9
10
11
12
13
# File 'lib/www/mechanize/form/radio_button.rb', line 9

def initialize(name, value, checked, form)
  @checked = checked
  @form    = form
  super(name, value)
end

Instance Attribute Details

#checkedObject

Returns the value of attribute checked.



7
8
9
# File 'lib/www/mechanize/form/radio_button.rb', line 7

def checked
  @checked
end

Instance Method Details

#checkObject



15
16
17
18
# File 'lib/www/mechanize/form/radio_button.rb', line 15

def check
  uncheck_peers
  @checked = true
end

#clickObject



24
25
26
# File 'lib/www/mechanize/form/radio_button.rb', line 24

def click
  checked ? uncheck : check
end

#pretty_print_instance_variablesObject



83
84
85
# File 'lib/www/mechanize/inspect.rb', line 83

def pretty_print_instance_variables
  [:@checked, :@name, :@value]
end

#uncheckObject



20
21
22
# File 'lib/www/mechanize/form/radio_button.rb', line 20

def uncheck
  @checked = false
end