Module: Bewildr::ControlTypeAdditions::MenuAdditions
- Defined in:
- lib/bewildr/control_type_additions/menu_additions.rb
Instance Method Summary collapse
-
#contains_menu_item?(path) ⇒ Boolean
Returns true if the menu contains the item described by the input, false if it doesn’t.
-
#menu_item(path) ⇒ Object
Returns the menu item described by the input, eg: menu_item([“File”, “Close”]).
-
#root_menu_item_names ⇒ Object
Returns a string array containing the root items’ names.
-
#root_menu_items ⇒ Object
Returns an array containing the menu’s root items.
-
#select_menu(path) ⇒ Object
Clicks the menu described by the input, eg: select_menu([“File”, “Close”]).
-
#select_node(path) ⇒ Object
Selects the menu described by the input, eg: select_node([“File”, “Close”]).
Instance Method Details
#contains_menu_item?(path) ⇒ Boolean
Returns true if the menu contains the item described by the input, false if it doesn’t
55 56 57 58 59 60 61 62 |
# File 'lib/bewildr/control_type_additions/menu_additions.rb', line 55 def (path) begin (path) return true rescue ElementDoesntExist => e return false end end |
#menu_item(path) ⇒ Object
Returns the menu item described by the input, eg:
(["File", "Close"])
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/bewildr/control_type_additions/menu_additions.rb', line 30 def (path) = = nil path.each_with_index do |, index| case when Array = .find {|node| node.name == } #TODO: make this work with regexes as well as strings... raise Bewildr::ElementDoesntExist if .nil? when Bewildr::Element if .name == #TODO: make this work with regexes as well as strings... = else raise Bewildr::ElementDoesntExist end end raise Bewildr::ElementDoesntExist if .nil? if path.size != index + 1 . = . end end return end |
#root_menu_item_names ⇒ Object
Returns a string array containing the root items’ names
12 13 14 |
# File 'lib/bewildr/control_type_additions/menu_additions.rb', line 12 def .collect {|| .name} end |
#root_menu_items ⇒ Object
Returns an array containing the menu’s root items
7 8 9 |
# File 'lib/bewildr/control_type_additions/menu_additions.rb', line 7 def get(:type => :menu_item, :scope => :children, :how_many => :all) end |
#select_menu(path) ⇒ Object
Clicks the menu described by the input, eg:
(["File", "Close"])
18 19 20 |
# File 'lib/bewildr/control_type_additions/menu_additions.rb', line 18 def (path) (path).click end |
#select_node(path) ⇒ Object
Selects the menu described by the input, eg:
select_node(["File", "Close"])
24 25 26 |
# File 'lib/bewildr/control_type_additions/menu_additions.rb', line 24 def select_node(path) node(path).select end |