class DialogTui::UserAction::UserActions

Constants

DSL_METHODS

Public Class Methods

new() { |self| ... } click to toggle source
# File lib/dialog_tui/user_action.rb, line 21
def initialize
  @actions = []
  yield self
end
run(&block) click to toggle source
# File lib/dialog_tui/user_action.rb, line 17
def self.run &block
  new(&block).run
end

Public Instance Methods

run() click to toggle source
# File lib/dialog_tui/user_action.rb, line 46
def run
  loop {
    input = UserAction.read_char
    matched = @actions.select { |x| x.matches? input }

    if matched.any?
      matched.each &:call
      break
    else
      # just ignore and wait for next input
    end
  }
end