Class: Metallize::Form::Option

Inherits:
Object
  • Object
show all
Defined in:
lib/metallize/form/option.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nodeObject (readonly)

Returns the value of attribute node.



3
4
5
# File 'lib/metallize/form/option.rb', line 3

def node
  @node
end

#select_listObject (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

#selectedObject (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

#textObject (readonly)

Returns the value of attribute text.



3
4
5
# File 'lib/metallize/form/option.rb', line 3

def text
  @text
end

#valueObject (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

Returns:

  • (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

#selectObject 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

#unselectObject Also known as: untick

Unselect this option



33
34
35
# File 'lib/metallize/form/option.rb', line 33

def unselect
  @selected = false
end