Sha256: dc89d9f4442480c9ee77f1fbcde3e46cff3d1a95b2bf74b2af11fb7347dfc238

Contents?: true

Size: 829 Bytes

Versions: 23

Compression:

Stored size: 829 Bytes

Contents

module Vedeu

  # A single keypress or combination of keypresses bound to a specific action.
  #
  # @api private
  class Key

    # @!attribute [r] input
    # @return [String|Symbol] Returns the key defined.
    attr_reader :input
    alias_method :key, :input

    # Returns a new instance of Vedeu::Key.
    #
    # @param input [String|Symbol]
    # @param block [Proc]
    # @raise [InvalidSyntax] The required block was not given.
    # @return [Key]
    def initialize(input = nil, &block)
      fail InvalidSyntax, 'block not given' unless block_given?

      @input  = input
      @output = block
    end

    # Pressing the key will call the procedure.
    #
    # @return [|Symbol]
    def output
      @output.call
    end
    alias_method :action, :output
    alias_method :press, :output

  end # Key

end # Vedeu

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
vedeu-0.4.55 lib/vedeu/input/key.rb
vedeu-0.4.54 lib/vedeu/input/key.rb
vedeu-0.4.53 lib/vedeu/input/key.rb
vedeu-0.4.52 lib/vedeu/input/key.rb
vedeu-0.4.51 lib/vedeu/input/key.rb
vedeu-0.4.50 lib/vedeu/input/key.rb
vedeu-0.4.49 lib/vedeu/input/key.rb
vedeu-0.4.48 lib/vedeu/input/key.rb
vedeu-0.4.47 lib/vedeu/input/key.rb
vedeu-0.4.46 lib/vedeu/input/key.rb
vedeu-0.4.45 lib/vedeu/input/key.rb
vedeu-0.4.44 lib/vedeu/input/key.rb
vedeu-0.4.43 lib/vedeu/input/key.rb
vedeu-0.4.42 lib/vedeu/input/key.rb
vedeu-0.4.41 lib/vedeu/input/key.rb
vedeu-0.4.40 lib/vedeu/input/key.rb
vedeu-0.4.39 lib/vedeu/input/key.rb
vedeu-0.4.38 lib/vedeu/input/key.rb
vedeu-0.4.37 lib/vedeu/input/key.rb
vedeu-0.4.36 lib/vedeu/input/key.rb