Class: TTY::MenuTree::ExitAction

Inherits:
Action
  • Object
show all
Defined in:
lib/tty/menu_tree/exit_action.rb

Overview

A ready-made action that ends the top-level menu loop when selected.

Examples:

Custom label

TTY::MenuTree::ExitAction.new(name: "Quit")

Constant Summary collapse

DEFAULT_NAME =
"Exit"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Action

#submenu

Constructor Details

#initialize(name: DEFAULT_NAME) ⇒ ExitAction

Returns a new instance of ExitAction.

Parameters:

  • name (String) (defaults to: DEFAULT_NAME) —

    label shown in the menu.



18
19
20
21
# File 'lib/tty/menu_tree/exit_action.rb', line 18

def initialize(name: DEFAULT_NAME)
  super()
  @name = name
end

Instance Attribute Details

#name ⇒ String (readonly)

Returns the label shown for this action.

Returns:

  • (String) —

    the label shown for this action.



15
16
17
# File 'lib/tty/menu_tree/exit_action.rb', line 15

def name
  @name
end

Instance Method Details

#call ⇒ void

This method returns an undefined value.

No-op; selecting this action ends the loop rather than doing work.



25
# File 'lib/tty/menu_tree/exit_action.rb', line 25

def call; end

#exit? ⇒ true

Returns:

  • (true)


28
29
30
# File 'lib/tty/menu_tree/exit_action.rb', line 28

def exit?
  true
end