Class: YuiRestClient::Widgets::Base
- Inherits:
-
Object
- Object
- YuiRestClient::Widgets::Base
- Includes:
- YuiRestClient::Waitable
- Defined in:
- lib/yui_rest_client/widgets/base.rb
Direct Known Subclasses
Bargraph, Button, Checkbox, Combobox, Datefield, Label, Menucollection, Multilinebox, Numberbox, Progressbar, Radiobutton, Richtext, Selectionbox, Tab, Table, Textbox, Timefield, Tree, Wizard
Instance Method Summary collapse
-
#action(params) ⇒ Object
This method can be used to send any action to widget.
-
#collect_all ⇒ Array
Get all widgets found with filter.
-
#debug_label ⇒ String
Returns debug_label value for widget.
-
#enabled? ⇒ Boolean
Allows to check if widget enabled or disabled.
-
#exists? ⇒ Boolean
Allows to check if widget exists on the current screen or not.
-
#initialize(widget_controller, filter) ⇒ Base
constructor
A new instance of Base.
-
#property(property) ⇒ Object
Returns value of widget property.
Methods included from YuiRestClient::Waitable
Constructor Details
#initialize(widget_controller, filter) ⇒ Base
Returns a new instance of Base.
8 9 10 11 |
# File 'lib/yui_rest_client/widgets/base.rb', line 8 def initialize(, filter) @widget_controller = @filter = filter end |
Instance Method Details
#action(params) ⇒ Object
This method can be used to send any action to widget. Can be called against any widget.
75 76 77 78 79 80 81 82 |
# File 'lib/yui_rest_client/widgets/base.rb', line 75 def action(params) unless @filter.regex.empty? = .first @filter = FilterExtractor.new() end YuiRestClient.logger.info("Send #{params} action for #{class_name} #{@filter}") @widget_controller.send_action(@filter.plain, params) end |
#collect_all ⇒ Array
Get all widgets found with filter. The method is mainly introduced for “class” filter, which can return an array of widgets. It only makes sense to use this method whenever server side filters allow to find individually those collected widgets, otherwise those will not be able to access their internal properties. Then actions that are specified for the widget can be called while iterating over the returned array.
93 94 95 96 97 98 99 100 |
# File 'lib/yui_rest_client/widgets/base.rb', line 93 def collect_all YuiRestClient.logger.info("Collect all #{class_name} widgets with filter #{@filter}") = YuiRestClient.logger.info("Found widgets for filter #{@filter}: #{}") .map do || self.class.new(@widget_controller, FilterExtractor.new()) end end |
#debug_label ⇒ String
Returns debug_label value for widget. Can be called against any widget.
51 52 53 |
# File 'lib/yui_rest_client/widgets/base.rb', line 51 def debug_label property(:debug_label) end |
#enabled? ⇒ Boolean
Allows to check if widget enabled or disabled. Can be called against any widget. Widget that does not have “enabled” property is counted as enabled.
33 34 35 36 |
# File 'lib/yui_rest_client/widgets/base.rb', line 33 def enabled? enabled_prop = property(:enabled) enabled_prop.nil? || enabled_prop == true end |
#exists? ⇒ Boolean
Allows to check if widget exists on the current screen or not. Can be called against any widget.
18 19 20 21 22 23 24 25 26 |
# File 'lib/yui_rest_client/widgets/base.rb', line 18 def exists? YuiRestClient.logger.info("Checking if #{class_name} with #{@filter} exists") YuiRestClient.logger.info("#{class_name} exists: #{@filter}") true rescue Error::WidgetNotFoundError YuiRestClient.logger.info("#{class_name} does not exist: #{@filter}") false end |
#property(property) ⇒ Object
Returns value of widget property. This method can be used to retrieve value of some specific property, but widget does not have a method to return the value. Can be called against any widget.
63 64 65 66 67 68 |
# File 'lib/yui_rest_client/widgets/base.rb', line 63 def property(property) YuiRestClient.logger.info("Get #{property} for #{class_name} #{@filter}") result = .first[property.to_sym] YuiRestClient.logger.info("Found '#{property}=#{result}' for #{class_name} #{@filter}") result end |