Class: Aidp::Harness::UI::Navigation::MenuItem
- Inherits:
-
Object
- Object
- Aidp::Harness::UI::Navigation::MenuItem
- Defined in:
- lib/aidp/harness/ui/navigation/menu_item.rb
Overview
Represents a single menu item in the navigation system
Defined Under Namespace
Classes: InvalidTypeError, MenuItemError
Constant Summary collapse
- VALID_TYPES =
[:action, :submenu, :workflow, :separator].freeze
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#shortcut ⇒ Object
readonly
Returns the value of attribute shortcut.
-
#submenu ⇒ Object
readonly
Returns the value of attribute submenu.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#visible ⇒ Object
Returns the value of attribute visible.
-
#workflow ⇒ Object
readonly
Returns the value of attribute workflow.
Instance Method Summary collapse
- #action? ⇒ Boolean
- #disabled? ⇒ Boolean
- #enabled? ⇒ Boolean
- #execute ⇒ Object
- #hidden? ⇒ Boolean
-
#initialize(title, type = :action, options = {}) ⇒ MenuItem
constructor
A new instance of MenuItem.
- #separator? ⇒ Boolean
- #submenu? ⇒ Boolean
- #to_s ⇒ Object
- #visible? ⇒ Boolean
- #workflow? ⇒ Boolean
Constructor Details
#initialize(title, type = :action, options = {}) ⇒ MenuItem
Returns a new instance of MenuItem.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/aidp/harness/ui/navigation/menu_item.rb', line 15 def initialize(title, type = :action, = {}) @title = title @type = type @action = [:action] @workflow = [:workflow] = [:submenu] @description = [:description] @shortcut = [:shortcut] @enabled = .fetch(:enabled, true) @visible = .fetch(:visible, true) validate_attributes end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
29 30 31 |
# File 'lib/aidp/harness/ui/navigation/menu_item.rb', line 29 def action @action end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
29 30 31 |
# File 'lib/aidp/harness/ui/navigation/menu_item.rb', line 29 def description @description end |
#enabled ⇒ Object
Returns the value of attribute enabled.
30 31 32 |
# File 'lib/aidp/harness/ui/navigation/menu_item.rb', line 30 def enabled @enabled end |
#shortcut ⇒ Object (readonly)
Returns the value of attribute shortcut.
29 30 31 |
# File 'lib/aidp/harness/ui/navigation/menu_item.rb', line 29 def shortcut @shortcut end |
#submenu ⇒ Object (readonly)
Returns the value of attribute submenu.
29 30 31 |
# File 'lib/aidp/harness/ui/navigation/menu_item.rb', line 29 def end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
29 30 31 |
# File 'lib/aidp/harness/ui/navigation/menu_item.rb', line 29 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
29 30 31 |
# File 'lib/aidp/harness/ui/navigation/menu_item.rb', line 29 def type @type end |
#visible ⇒ Object
Returns the value of attribute visible.
30 31 32 |
# File 'lib/aidp/harness/ui/navigation/menu_item.rb', line 30 def visible @visible end |
#workflow ⇒ Object (readonly)
Returns the value of attribute workflow.
29 30 31 |
# File 'lib/aidp/harness/ui/navigation/menu_item.rb', line 29 def workflow @workflow end |
Instance Method Details
#action? ⇒ Boolean
32 33 34 |
# File 'lib/aidp/harness/ui/navigation/menu_item.rb', line 32 def action? @type == :action end |
#disabled? ⇒ Boolean
56 57 58 |
# File 'lib/aidp/harness/ui/navigation/menu_item.rb', line 56 def disabled? !enabled? end |
#enabled? ⇒ Boolean
48 49 50 |
# File 'lib/aidp/harness/ui/navigation/menu_item.rb', line 48 def enabled? @enabled end |
#execute ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/aidp/harness/ui/navigation/menu_item.rb', line 64 def execute case @type when :action execute_action when :workflow execute_workflow when :submenu when :separator execute_separator else raise InvalidTypeError, "Unknown menu item type: #{@type}" end end |
#hidden? ⇒ Boolean
60 61 62 |
# File 'lib/aidp/harness/ui/navigation/menu_item.rb', line 60 def hidden? !visible? end |
#separator? ⇒ Boolean
44 45 46 |
# File 'lib/aidp/harness/ui/navigation/menu_item.rb', line 44 def separator? @type == :separator end |
#submenu? ⇒ Boolean
36 37 38 |
# File 'lib/aidp/harness/ui/navigation/menu_item.rb', line 36 def @type == :submenu end |
#to_s ⇒ Object
79 80 81 |
# File 'lib/aidp/harness/ui/navigation/menu_item.rb', line 79 def to_s "#{@title} (#{@type})" end |
#visible? ⇒ Boolean
52 53 54 |
# File 'lib/aidp/harness/ui/navigation/menu_item.rb', line 52 def visible? @visible end |
#workflow? ⇒ Boolean
40 41 42 |
# File 'lib/aidp/harness/ui/navigation/menu_item.rb', line 40 def workflow? @type == :workflow end |