Class: Dill::Select
Overview
A select.
Defined Under Namespace
Modules: Selectable
Constant Summary
Constants included from Dill
Instance Attribute Summary
Attributes inherited from Widget
Instance Method Summary collapse
-
#get ⇒ String
The text of the selected option.
-
#set(option) ⇒ Object
Selects the given
option
. - #to_cell ⇒ Object
-
#to_s ⇒ Object
The text of the selected option, or the empty string if no option is selected.
Methods inherited from Field
Methods inherited from Widget
action, #class?, #classes, #click, filter, filter?, find_all_in, find_in, #has_action?, #hover, #html, #id, #initialize, not_present_in?, present_in?, root, selector, #text, #value, widget_delegator
Methods included from Widgets::DSL
Methods included from WidgetParts::Container
#has_widget?, #not_visible?, #visible?, #widget, #widgets
Methods included from Dill
Methods included from Constructors
Methods included from WidgetParts::Struct
Constructor Details
This class inherits a constructor from Dill::Widget
Instance Method Details
#get ⇒ String
Returns The text of the selected option.
23 24 25 |
# File 'lib/dill/widgets/select.rb', line 23 def get visible?(:selected) ? (:selected).text : nil end |
#set(option) ⇒ Object
Selects the given option
.
You may pass in the option text or value.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/dill/widgets/select.rb', line 30 def set(option) (:option, option).select rescue begin (:option_by_value, option).select rescue Dill::MissingWidget => e raise InvalidOption.new(e.). tap { |x| x.set_backtrace e.backtrace } end end |
#to_cell ⇒ Object
46 47 48 |
# File 'lib/dill/widgets/select.rb', line 46 def to_cell get end |
#to_s ⇒ Object
Returns the text of the selected option, or the empty string if no option is selected.
44 |
# File 'lib/dill/widgets/select.rb', line 44 def_delegator :get, :to_s |