Class: Dill::RadioButton

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

Overview

A radio button.

Constant Summary

Constants included from Dill

VERSION

Instance Attribute Summary

Attributes inherited from Widget

#root

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Widget

action, #class?, #classes, #click, #double_click, filter, filter?, find_all_in, find_in, #has_action?, #hover, #html, #initialize, not_present_in?, present_in?, #right_click, selector, #text, #to_s, 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

Class Method Details

.root(selector) ⇒ Object



16
17
18
# File 'lib/dill/widgets/radio_button.rb', line 16

def self.root(selector)
  super(["#{selector}"])
end

Instance Method Details

#getObject

no button is checked.

Returns:

  • the text of the checked button, or an empty string if



21
22
23
24
25
26
27
28
29
# File 'lib/dill/widgets/radio_button.rb', line 21

def get
  if visible?(:checked_label_by_value, value)
    widget(:checked_label_by_value, value).text
  elsif visible?(:checked_label_by_id, id)
    widget(:checked_label_by_id, id).text
  else
    nil
  end
end

#idString

Returns The id of the checked button.

Returns:

  • (String)

    The id of the checked button.



37
38
39
# File 'lib/dill/widgets/radio_button.rb', line 37

def id
  visible?(:checked) ? widget(:checked).id : nil
end

#set(str) ⇒ Object

First attempts to choose the button by id or label text Then attempts to choose the button by value



43
44
45
46
47
48
49
50
51
52
# File 'lib/dill/widgets/radio_button.rb', line 43

def set(str)
  root.choose(str)
rescue
  begin
    widget(:button_by_value, str).root.set(true)
  rescue Dill::MissingWidget => e
    raise InvalidRadioButton.new(e.message).
      tap { |x| x.set_backtrace e.backtrace }
  end
end

#to_cellObject



58
59
60
# File 'lib/dill/widgets/radio_button.rb', line 58

def to_cell
  get
end

#valueString

Returns The value of the checked button.

Returns:

  • (String)

    The value of the checked button.



32
33
34
# File 'lib/dill/widgets/radio_button.rb', line 32

def value
  visible?(:checked) ? widget(:checked).root.value : nil
end