class Metallize::Form::Option

Attributes

node[R]
select_list[R]
selected[R]
selected?[R]
text[R]
value[R]

Public Class Methods

new(node, select_list) click to toggle source
# 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

Public Instance Methods

has_attribute?(node, attr) click to toggle source
# File lib/metallize/form/option.rb, line 7
def has_attribute?(node, attr)
  if node.attribute(attr)
    true
  else
    false
  end
end
select() click to toggle source

Select this option

# File lib/metallize/form/option.rb, line 25
def select
  unselect_peers
  @selected = true
  # option = Selenium::WebDriver::Support::Select.new(node)
  # option
end
Also aliased as: tick
tick()
Alias for: select
unselect() click to toggle source

Unselect this option

# File lib/metallize/form/option.rb, line 33
def unselect
  @selected = false
end
Also aliased as: untick
untick()
Alias for: unselect

Private Instance Methods

unselect_peers() click to toggle source
# File lib/metallize/form/option.rb, line 42
def unselect_peers
  # return unless Mechanize::Form::SelectList === @select_list

  @select_list.select_none
end