Module: Vapir::SelectList
- Extended by:
- ElementHelper
- Defined in:
- lib/vapir-common/elements/elements.rb
Instance Method Summary collapse
-
#[](index) ⇒ Object
note that the above is defined that way rather than with element_collection, as below, because adding :select_list => self to extra isn’t implemented yet element_collection :options, :options, Option, proc { => self }.
-
#clear ⇒ Object
(also: #clearSelection)
Clears the selected items in the select box.
- #option_texts ⇒ Object
-
#option_texts_include?(text_or_regexp) ⇒ Boolean
(also: #include?, #includes?)
Does the SelectList have an option whose text matches the given text or regexp?.
-
#options ⇒ Object
Returns an ElementCollection containing all the option elements of the select list Raises UnknownObjectException if the select box is not found.
-
#select_text(option_text, method_options = {}) ⇒ Object
(also: #select, #set)
selects options whose text matches the given text.
-
#select_value(option_value, method_options = {}) ⇒ Object
selects options whose value matches the given value.
- #selected_option_texts ⇒ Object
-
#selected_option_texts_include?(text_or_regexp) ⇒ Boolean
(also: #selected?)
Is the specified option (text) selected? Raises exception of option does not exist.
-
#selected_options ⇒ Object
Returns an array of selected option Elements in this select list.
Methods included from ElementHelper
add_specifier, container_collection_method, container_single_method, included
Methods included from ElementClassAndModuleMethods
#add_container_method_extra_args, #all_dom_attr_aliases, #all_dom_attrs, #class_array_append, #class_array_get, #class_hash_get, #class_hash_merge, #container_collection_methods, #container_method_extra_args, #container_single_methods, #default_how, #dom_attr, #dom_attr_locate_alias, #dom_function, #dom_setter, #element_collection, #factory, #inspect_these, #inspect_this_if, #parent_element_module, #set_or_get_class_var, #specifiers
Instance Method Details
#[](index) ⇒ Object
note that the above is defined that way rather than with element_collection, as below, because adding :select_list => self to extra isn’t implemented yet element_collection :options, :options, Option, proc { => self }
351 352 353 |
# File 'lib/vapir-common/elements/elements.rb', line 351 def [](index) [index] end |
#clear ⇒ Object Also known as: clearSelection
Clears the selected items in the select box.
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
# File 'lib/vapir-common/elements/elements.rb', line 356 def clear with_highlight do assert_enabled changed=false .each do |option| if option.selected option.selected=false changed=true end end if changed fire_event :onchange wait end end end |
#option_texts ⇒ Object
412 413 414 |
# File 'lib/vapir-common/elements/elements.rb', line 412 def option_texts .map{|o| o.text } end |
#option_texts_include?(text_or_regexp) ⇒ Boolean Also known as: include?, includes?
Does the SelectList have an option whose text matches the given text or regexp?
397 398 399 |
# File 'lib/vapir-common/elements/elements.rb', line 397 def option_texts_include?(text_or_regexp) option_texts.grep(text_or_regexp).size > 0 end |
#options ⇒ Object
Returns an ElementCollection containing all the option elements of the select list Raises UnknownObjectException if the select box is not found
343 344 345 346 347 |
# File 'lib/vapir-common/elements/elements.rb', line 343 def assert_exists do ElementCollection.new(self, element_class_for(Vapir::Option), extra_for_contained.merge(:candidates => :options, :select_list => self)) end end |
#select_text(option_text, method_options = {}) ⇒ Object Also known as: select, set
selects options whose text matches the given text. Raises NoValueFoundException if the specified value is not found.
takes method_options hash (note, these are flags for the function, not to be confused with the Options of the select list)
-
:wait => true/false default true. controls whether #wait is called and whether fire_event or fire_event_no_wait is used for the onchange event.
380 381 382 |
# File 'lib/vapir-common/elements/elements.rb', line 380 def select_text(option_text, ={}) () {|option| Vapir::fuzzy_match(option.text, option_text) } end |
#select_value(option_value, method_options = {}) ⇒ Object
selects options whose value matches the given value. Raises NoValueFoundException if the specified value is not found.
takes options hash (note, these are flags for the function, not to be confused with the Options of the select list)
-
:wait => true/false default true. controls whether #wait is called and whether fire_event or fire_event_no_wait is used for the onchange event.
392 393 394 |
# File 'lib/vapir-common/elements/elements.rb', line 392 def select_value(option_value, ={}) () {|option| Vapir::fuzzy_match(option.value, option_value) } end |
#selected_option_texts ⇒ Object
423 424 425 |
# File 'lib/vapir-common/elements/elements.rb', line 423 def selected_option_texts .map{|o| o.text } end |
#selected_option_texts_include?(text_or_regexp) ⇒ Boolean Also known as: selected?
Is the specified option (text) selected? Raises exception of option does not exist.
404 405 406 407 408 409 |
# File 'lib/vapir-common/elements/elements.rb', line 404 def selected_option_texts_include?(text_or_regexp) unless includes? text_or_regexp raise Vapir::Exception::UnknownObjectException, "Option #{text_or_regexp.inspect} not found." end selected_option_texts.grep(text_or_regexp).size > 0 end |
#selected_options ⇒ Object
Returns an array of selected option Elements in this select list.
An empty array is returned if the select box has no selected item.
419 420 421 |
# File 'lib/vapir-common/elements/elements.rb', line 419 def .select{|o|o.selected} end |