Class: Dill::FieldGroup::Select

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

Overview

A select.

Instance Attribute Summary

Attributes inherited from Widget

#root

Instance Method Summary collapse

Methods inherited from Field

find_in, present_in?

Methods inherited from Widget

#!=, #!~, #<, #<=, #==, #=~, #>, #>=, action, #click, #diff, find_in, #has_action?, #initialize, #inspect, #match, present_in?, #reload, root, selector, #text, #to_cell, #to_f, #to_i, widget, widget_delegator

Methods included from WidgetContainer

#has_widget?, #widget

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.



294
295
296
297
298
# File 'lib/dill/field_group.rb', line 294

def get
  option = root.find('[selected]') rescue nil

  option && option.text
end

#set(option) ⇒ Object

Selects the given option.

Parameters:

  • option (String)

    The text of the option to select.



303
304
305
# File 'lib/dill/field_group.rb', line 303

def set(option)
  root.find('option', text: option).select_option
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.



310
# File 'lib/dill/field_group.rb', line 310

def_delegator :get, :to_s