Class: Dill::Select

Inherits:
Field show all
Defined in:
lib/dill/widgets/select.rb

Overview

A select.

Defined Under Namespace

Modules: Selectable

Constant Summary

Constants included from Dill

VERSION

Instance Attribute Summary

Attributes inherited from Widget

#root

Instance Method Summary collapse

Methods inherited from Field

root

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

#form, #list, #widget

Methods included from WidgetParts::Container

#has_widget?, #not_visible?, #visible?, #widget, #widgets

Methods included from Dill

#deprecate

Methods included from Constructors

#Decimal, #Integer, #Widget

Methods included from WidgetParts::Struct

included

Constructor Details

This class inherits a constructor from Dill::Widget

Instance Method Details

#getString

Returns The text of the selected option.

Returns:

  • (String)

    The text of the selected option.



23
24
25
# File 'lib/dill/widgets/select.rb', line 23

def get
  visible?(:selected) ? widget(: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)
  widget(:option, option).select
rescue
  begin
    widget(:option_by_value, option).select
  rescue Dill::MissingWidget => e
    raise InvalidOption.new(e.message).
      tap { |x| x.set_backtrace e.backtrace }
  end
end

#to_cellObject



46
47
48
# File 'lib/dill/widgets/select.rb', line 46

def to_cell
  get
end

#to_sObject

Returns the text of the selected option, or the empty string if no option is selected.

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