class YuiRestClient::Widgets::Selectionbox

Class representing a selectionbox in the UI. It can be YSelectionBox.

Public Instance Methods

items() click to toggle source

Returns the list of items available to select from selection box. @return [Array] array of String objects. @example Get items from selection box with id “test_id”

{
  "class" : "YSelectionBox",
  "debug_label" : "selection box title",
  "hstretch" : true,
  "icon_base_path" : "",
  "id" : "test_id",
  "items" :
  [
    {
      "label" : "selection 1",
      "selected" : true
    },
    {
      "label" : "selection 2"
    },
    {
      "label" : "selection 3"
    }
  ],
  "items_count" : 3,
  "label" : "&selection box title",
  "vstretch" : true
}

@example

app.selectionbox(id: 'test_id').items
# selection 1
# selection 2
# selection 3
# File lib/yui_rest_client/widgets/selectionbox.rb, line 39
def items
  property(:items).map { |x| x[:label] }
end
select(item) click to toggle source

Sends action to click the selection in UI. @param item [String] value to select from items. @return [Selectionbox] in case action is successful @example Click selection with id 'test_id'

app.selectionbox(id: 'test_id').select('item_id')
# File lib/yui_rest_client/widgets/selectionbox.rb, line 48
def select(item)
  action(action: Actions::SELECT, value: item)
  self
end
selected_item() click to toggle source

Returns selected item in selection box. @example Get selected item in selection box with id “test_id”

{
  "class" : "YSelectionBox",
  "debug_label" : "selection box title",
  "hstretch" : true,
  "icon_base_path" : "",
  "id" : "test_id",
  "items" :
  [
    {
      "label" : "selection 1",
      "selected" : true
    },
    {
      "label" : "selection 2"
    },
    {
      "label" : "selection 3"
    }
  ],
  "items_count" : 3,
  "label" : "&selection box title",
  "vstretch" : true
}

@example

app.selectionbox(id: 'test_id').selected_item
# selection 1
# File lib/yui_rest_client/widgets/selectionbox.rb, line 82
def selected_item
  property(:items).select { |x| x[:selected] }.first[:label]
end