Module: Lich::Common::ShutdownIntent

Defined in:
documented/common/shutdown_intent.rb

Overview

Detects explicit frontend shutdown commands.

Constant Summary collapse

USER_EXIT_COMMAND =

Regexp pattern that matches frontend shutdown commands.

Matches "exit" or "quit" (case-insensitive) with optional whitespace, optionally preceded by a <c> XML tag marker. Anchored to match the entire string.

Examples:

ShutdownIntent::USER_EXIT_COMMAND.match?("exit")      #=> true
ShutdownIntent::USER_EXIT_COMMAND.match?("QUIT")      #=> true
ShutdownIntent::USER_EXIT_COMMAND.match?("  <c> exit") #=> true
ShutdownIntent::USER_EXIT_COMMAND.match?("stand")     #=> false

Returns:

  • (Regexp)

    pattern for shutdown command detection

See Also:

/\A\s*(?:<c>)?\s*(?:exit|quit)\s*\z/i

Class Method Summary collapse

Class Method Details

.user_exit_command?(client_string) ⇒ Boolean

Detects whether a client string is an explicit frontend shutdown command.

Returns true if the string matches an exit or quit command, false otherwise. Safely handles nil input by returning false.

Examples:

ShutdownIntent.user_exit_command?("exit")  #=> true
ShutdownIntent.user_exit_command?("quit")  #=> true
ShutdownIntent.user_exit_command?(nil)     #=> false
ShutdownIntent.user_exit_command?("stand") #=> false

Parameters:

  • client_string (String, nil)

    the client input to test

Returns:

  • (Boolean)

    true if the string matches a shutdown command

See Also:



36
37
38
39
40
# File 'documented/common/shutdown_intent.rb', line 36

def self.user_exit_command?(client_string)
  return false if client_string.nil?

  USER_EXIT_COMMAND.match?(client_string.to_s)
end