Class: Metallize::Form::Option
- Inherits:
-
Object
- Object
- Metallize::Form::Option
- Defined in:
- lib/metallize/form/option.rb
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#select_list ⇒ Object
readonly
Returns the value of attribute select_list.
-
#selected ⇒ Object
(also: #selected?)
readonly
Returns the value of attribute selected.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #has_attribute?(node, attr) ⇒ Boolean
-
#initialize(node, select_list) ⇒ Option
constructor
A new instance of Option.
-
#select ⇒ Object
(also: #tick)
Select this option.
-
#unselect ⇒ Object
(also: #untick)
Unselect this option.
Constructor Details
#initialize(node, select_list) ⇒ Option
Returns a new instance of Option.
15 16 17 18 19 20 21 |
# File 'lib/metallize/form/option.rb', line 15 def initialize(node, select_list) @node = node @text = node.attribute('innerText') @value = node.attribute('value') || node.attribute('innerText') @selected = has_attribute? node, 'selected' @select_list = select_list # The select list this option belongs to end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
3 4 5 |
# File 'lib/metallize/form/option.rb', line 3 def node @node end |
#select_list ⇒ Object (readonly)
Returns the value of attribute select_list.
3 4 5 |
# File 'lib/metallize/form/option.rb', line 3 def select_list @select_list end |
#selected ⇒ Object (readonly) Also known as: selected?
Returns the value of attribute selected.
3 4 5 |
# File 'lib/metallize/form/option.rb', line 3 def selected @selected end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
3 4 5 |
# File 'lib/metallize/form/option.rb', line 3 def text @text end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
3 4 5 |
# File 'lib/metallize/form/option.rb', line 3 def value @value end |
Instance Method Details
#has_attribute?(node, attr) ⇒ Boolean
7 8 9 10 11 12 13 |
# File 'lib/metallize/form/option.rb', line 7 def has_attribute?(node, attr) if node.attribute(attr) true else false end end |
#select ⇒ Object Also known as: tick
Select this option
25 26 27 28 29 30 |
# File 'lib/metallize/form/option.rb', line 25 def select unselect_peers @selected = true # option = Selenium::WebDriver::Support::Select.new(node) # option end |
#unselect ⇒ Object Also known as: untick
Unselect this option
33 34 35 |
# File 'lib/metallize/form/option.rb', line 33 def unselect @selected = false end |