Class: YuiRestClient::App

Inherits:
Object
  • Object
show all
Defined in:
lib/yui_rest_client/app.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host:, port:) ⇒ App

Used to initialize main entry point of YuiRestClient and set host and port for the application under control.

Parameters:

  • host (String)

    host address (e.g. ‘localhost’, ‘192.168.0.1’)

  • port (String)

    port opened for communication (e.g. ‘9999’)



11
12
13
14
15
16
# File 'lib/yui_rest_client/app.rb', line 11

def initialize(host:, port:)
  @host = host
  @port = port
  @widget_controller = Http::WidgetController.new(host: host, port: port)
  @version_controller = Http::VersionController.new(host: host, port: port)
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



5
6
7
# File 'lib/yui_rest_client/app.rb', line 5

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



5
6
7
# File 'lib/yui_rest_client/app.rb', line 5

def port
  @port
end

Instance Method Details

#bargraph(filter) ⇒ Widgets::Bargraph

Initializes new instance of Bargraph with the filter provided. Does not make request to libyui-rest-api.

Examples:

app.bargraph(id: 'id', label: 'label', class: 'YBarGraph')

Parameters:

  • filter (Hash)

    filter to find a widget

Returns:



34
35
36
# File 'lib/yui_rest_client/app.rb', line 34

def bargraph(filter)
  Widgets::Bargraph.new(@widget_controller, FilterExtractor.new(filter))
end

#button(filter) ⇒ Widgets::Button

Initializes new instance of Button with the filter provided. Does not make request to libyui-rest-api.

Examples:

app.button(id: 'id', label: 'label', class: 'YPushButton')

Parameters:

  • filter (Hash)

    filter to find a widget

Returns:



44
45
46
# File 'lib/yui_rest_client/app.rb', line 44

def button(filter)
  Widgets::Button.new(@widget_controller, FilterExtractor.new(filter))
end

#check_api_versionObject

Validates if server side REST API is compatible with client inside

Returns:

  • true if version is compatible, false if not or any error while receiving version from the server

Raises:



233
234
235
236
237
238
239
240
# File 'lib/yui_rest_client/app.rb', line 233

def check_api_version
  YuiRestClient.logger.info("Client API version: #{API_VERSION}")
  server_api_v = server_api_version
  raise Error::YuiRestClientError if server_api_v.nil?

  YuiRestClient.logger.info("Server API version: #{server_api_v}")
  server_api_v <= client_api_version
end

#checkbox(filter) ⇒ Widgets::Checkbox

Initializes new instance of Checkbox with the filter provided. Does not make request to libyui-rest-api.

Examples:

app.checkbox(id: 'id', label: 'label', class: 'YCheckBox')

Parameters:

  • filter (Hash)

    filter to find a widget

Returns:



54
55
56
# File 'lib/yui_rest_client/app.rb', line 54

def checkbox(filter)
  Widgets::Checkbox.new(@widget_controller, FilterExtractor.new(filter))
end

#client_api_versionObject

Returns client side libyui REST API version

Returns:

  • libyui client REST API version



220
221
222
# File 'lib/yui_rest_client/app.rb', line 220

def client_api_version
  API_VERSION
end

#combobox(filter) ⇒ Widgets::Combobox

Initializes new instance of Combobox with the filter provided. Does not make request to libyui-rest-api.

Examples:

app.combobox(id: 'id', label: 'label', class: 'YComboBox')

Parameters:

  • filter (Hash)

    filter to find a widget

Returns:



64
65
66
# File 'lib/yui_rest_client/app.rb', line 64

def combobox(filter)
  Widgets::Combobox.new(@widget_controller, FilterExtractor.new(filter))
end

#connectObject

wait until the specified port is open or until the timeout is reached

Raises:

  • YuiRestClient::Error::TimeoutError if the port is not opened in time



20
21
22
23
24
25
26
# File 'lib/yui_rest_client/app.rb', line 20

def connect
  Wait.until(timeout: YuiRestClient.timeout, interval: YuiRestClient.interval) do
    YuiRestClient.logger.debug("Waiting for #{@host}:#{@port}...")
    port_open?
  end
  self
end

#datefield(filter) ⇒ Widgets::Datefield

Initializes new instance of Datefield with the filter provided. Does not make request to libyui-rest-api.

Examples:

app.datefield(id: 'id', label: 'label', class: 'YDateField')

Parameters:

  • filter (Hash)

    filter to find a widget

Returns:



74
75
76
# File 'lib/yui_rest_client/app.rb', line 74

def datefield(filter)
  Widgets::Datefield.new(@widget_controller, FilterExtractor.new(filter))
end

#label(filter) ⇒ Widgets::Label

Initializes new instance of Label with the filter provided. Does not make request to libyui-rest-api.

Examples:

app.label(id: 'id', label: 'label', class: 'YLabel')

Parameters:

  • filter (Hash)

    filter to find a widget

Returns:



84
85
86
# File 'lib/yui_rest_client/app.rb', line 84

def label(filter)
  Widgets::Label.new(@widget_controller, FilterExtractor.new(filter))
end

Initializes new instance of Menucollection with the filter provided. Does not make request to libyui-rest-api.

Examples:

app.menucollection(id: 'id', label: 'label', class: 'YMenuButton')

Parameters:

  • filter (Hash)

    filter to find a widget

Returns:



94
95
96
# File 'lib/yui_rest_client/app.rb', line 94

def menucollection(filter)
  Widgets::Menucollection.new(@widget_controller, FilterExtractor.new(filter))
end

#multilinebox(filter) ⇒ Widgets::Multilinebox

Initializes new instance of Multilinebox with the filter provided. Does not make request to libyui-rest-api.

Examples:

app.multilinebox(id: 'id', label: 'label', class: 'YMultiLineEdit')

Parameters:

  • filter (Hash)

    filter to find a widget

Returns:



104
105
106
# File 'lib/yui_rest_client/app.rb', line 104

def multilinebox(filter)
  Widgets::Multilinebox.new(@widget_controller, FilterExtractor.new(filter))
end

#numberbox(filter) ⇒ Widgets::Numberbox

Initializes new instance of Numberbox with the filter provided. Does not make request to libyui-rest-api.

Examples:

app.numberbox(id: 'id', label: 'label', class: 'YIntField')

Parameters:

  • filter (Hash)

    filter to find a widget

Returns:



114
115
116
# File 'lib/yui_rest_client/app.rb', line 114

def numberbox(filter)
  Widgets::Numberbox.new(@widget_controller, FilterExtractor.new(filter))
end

#progressbar(filter) ⇒ Widgets::Progressbar

Initializes new instance of Progressbar with the filter provided. Does not make request to libyui-rest-api.

Examples:

app.progressbar(id: 'id', label: 'label', class: 'YProgressBar')

Parameters:

  • filter (Hash)

    filter to find a widget

Returns:



124
125
126
# File 'lib/yui_rest_client/app.rb', line 124

def progressbar(filter)
  Widgets::Progressbar.new(@widget_controller, FilterExtractor.new(filter))
end

#radiobutton(filter) ⇒ Widgets::Radiobutton

Initializes new instance of Radiobutton with the filter provided. Does not make request to libyui-rest-api.

Examples:

app.radiobutton(id: 'id', label: 'label', class: 'YRadioButton')

Parameters:

  • filter (Hash)

    filter to find a widget

Returns:



134
135
136
# File 'lib/yui_rest_client/app.rb', line 134

def radiobutton(filter)
  Widgets::Radiobutton.new(@widget_controller, FilterExtractor.new(filter))
end

#richtext(filter) ⇒ Widgets::Richtext

Initializes new instance of Richtext with the filter provided. Does not make request to libyui-rest-api.

Examples:

app.richtext(id: 'id', label: 'label', class: 'YRichText')

Parameters:

  • filter (Hash)

    filter to find a widget

Returns:



144
145
146
# File 'lib/yui_rest_client/app.rb', line 144

def richtext(filter)
  Widgets::Richtext.new(@widget_controller, FilterExtractor.new(filter))
end

#selectionbox(filter) ⇒ Widgets::Selectionbox

Initializes new instance of Selectionbox with the filter provided. Does not make request to libyui-rest-api.

Examples:

app.selectionbox(id: 'id', label: 'label', class: 'YSelectionBox')

Parameters:

  • filter (Hash)

    filter to find a widget

Returns:



154
155
156
# File 'lib/yui_rest_client/app.rb', line 154

def selectionbox(filter)
  Widgets::Selectionbox.new(@widget_controller, FilterExtractor.new(filter))
end

#server_api_versionObject

Returns server side libyui REST API version

Returns:

  • libyui server REST API version



226
227
228
# File 'lib/yui_rest_client/app.rb', line 226

def server_api_version
  @version_controller.api_version
end

#tab(filter) ⇒ Widgets::Tab

Initializes new instance of Tab with the filter provided. Does not make request to libyui-rest-api.

Examples:

app.tab(id: 'id', label: 'label', class: 'YDumbTab')

Parameters:

  • filter (Hash)

    filter to find a widget

Returns:



164
165
166
# File 'lib/yui_rest_client/app.rb', line 164

def tab(filter)
  Widgets::Tab.new(@widget_controller, FilterExtractor.new(filter))
end

#table(filter) ⇒ Widgets::Table

Initializes new instance of Table with the filter provided. Does not make request to libyui-rest-api.

Examples:

app.table(id: 'id', label: 'label', class: 'YTable')

Parameters:

  • filter (Hash)

    filter to find a widget

Returns:



174
175
176
# File 'lib/yui_rest_client/app.rb', line 174

def table(filter)
  Widgets::Table.new(@widget_controller, FilterExtractor.new(filter))
end

#textbox(filter) ⇒ Widgets::Textbox

Initializes new instance of Textbox with the filter provided. Does not make request to libyui-rest-api.

Examples:

app.textbox(id: 'id', label: 'label', class: 'YInputField')

Parameters:

  • filter (Hash)

    filter to find a widget

Returns:



194
195
196
# File 'lib/yui_rest_client/app.rb', line 194

def textbox(filter)
  Widgets::Textbox.new(@widget_controller, FilterExtractor.new(filter))
end

#timefield(filter) ⇒ Widgets::Timefield

Initializes new instance of time field with the filter provided. Does not make request to libyui-rest-api.

Examples:

app.timefield(id: 'id', label: 'label', class: 'YTimeField')

Parameters:

  • filter (Hash)

    filter to find a widget

Returns:



184
185
186
# File 'lib/yui_rest_client/app.rb', line 184

def timefield(filter)
  Widgets::Timefield.new(@widget_controller, FilterExtractor.new(filter))
end

#tree(filter) ⇒ Widgets::Tree

Initializes new instance of Tree with the filter provided. Does not make request to libyui-rest-api.

Examples:

app.tree(id: 'id', label: 'label', class: 'YTree')

Parameters:

  • filter (Hash)

    filter to find a widget

Returns:



204
205
206
# File 'lib/yui_rest_client/app.rb', line 204

def tree(filter)
  Widgets::Tree.new(@widget_controller, FilterExtractor.new(filter))
end

#wizard(filter) ⇒ Widgets::Wizard

Initializes new instance of Wizard with the filter provided. Does not make request to libyui-rest-api.

Examples:

app.wizard(id: 'id', label: 'label', class: 'YWizard')

Parameters:

  • filter (Hash)

    filter to find a widget

Returns:



214
215
216
# File 'lib/yui_rest_client/app.rb', line 214

def wizard(filter)
  Widgets::Wizard.new(@widget_controller, FilterExtractor.new(filter))
end