Class: LessForm::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/less-form/options.rb

Instance Method Summary collapse

Constructor Details

#initialize(select_element) ⇒ Options

Returns a new instance of Options.



3
4
5
# File 'lib/less-form/options.rb', line 3

def initialize select_element
	@elements = select_element.find_elements(:css, 'option')
end

Instance Method Details

#allObject



7
8
9
# File 'lib/less-form/options.rb', line 7

def all
	@elements.map {|e| e.text }
end

#by_text(text) ⇒ Object



15
16
17
# File 'lib/less-form/options.rb', line 15

def by_text text
	Option.new @elements.detect {|e| e.text == text}
end

#by_value(value) ⇒ Object



11
12
13
# File 'lib/less-form/options.rb', line 11

def by_value value
	Option.new @elements.detect {|e| e.attribute('value') == value}
end

#selectedObject



19
20
21
# File 'lib/less-form/options.rb', line 19

def selected
	Option.new @elements.detect {|e| e.selected?}
end