module BBS::Hotkey
The hotkey of a label such as &File: the letter after the &. Buttons, menus and menu items mark their hotkeys this way.
BBS::Hotkey.letter('E&xit') # => "x" BBS::Hotkey.split('E&xit') # => ["E", "x", "it"] BBS::Hotkey.plain('E&xit') # => "Exit"
Public Instance Methods
Source
# File lib/bbs/hotkey.rb, line 23 def letter(label) = split(label)&.[](1)&.downcase
The hotkey letter of label, downcased, or nil.
Source
# File lib/bbs/hotkey.rb, line 26 def plain(label) = label.sub('&', '')
label without its & marker.
Source
# File lib/bbs/hotkey.rb, line 15 def split(label) idx = label.index('&') return nil unless idx && idx + 1 < label.length [label[0, idx], label[idx + 1], label[(idx + 2)..]] end
The label round its hotkey: [before, letter, after], or nil when label marks none.