Class: DialogTui::UserAction::Action
- Inherits:
-
Object
- Object
- DialogTui::UserAction::Action
- Defined in:
- lib/dialog_tui/user_action/action.rb
Constant Summary collapse
- CHARS =
any other mapping can be passed into constructor! sounds odd to pass it here, builder is a better idea, anyway strange class + builder hereā¦
{ ctrl_c: "\u0003", space: ' ', esc: "\e", escape: "\e", enter: "\r", return: "\r", up: "\e[A", down: "\e[B", right: "\e[C", left: "\e[D", }
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(name, mapping = CHARS, &block) ⇒ Action
constructor
A new instance of Action.
- #match?(input) ⇒ Boolean (also: #matches?)
Constructor Details
#initialize(name, mapping = CHARS, &block) ⇒ Action
Returns a new instance of Action.
5 6 7 8 |
# File 'lib/dialog_tui/user_action/action.rb', line 5 def initialize name, mapping=CHARS, &block @matches = mapping.fetch name.to_sym @block = block end |
Instance Method Details
#call ⇒ Object
19 20 21 |
# File 'lib/dialog_tui/user_action/action.rb', line 19 def call @block.call end |
#match?(input) ⇒ Boolean Also known as: matches?
13 14 15 |
# File 'lib/dialog_tui/user_action/action.rb', line 13 def match? input matches == input end |