Sha256: 2aa5364a657a5b3565d810f46b2caf0b3e74cba2b72634bbedaecd1999516e0b

Contents?: true

Size: 899 Bytes

Versions: 6

Compression:

Stored size: 899 Bytes

Contents

module Vedeu

  module Input

    # A single keypress or combination of keypresses bound to a
    # specific action.
    #
    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::Input::Key.
      #
      # @param input [String|Symbol]
      # @param block [Proc]
      # @raise [Vedeu::Error::RequiresBlock]
      # @return [Vedeu::Input::Key]
      def initialize(input = nil, &block)
        fail Vedeu::Error::RequiresBlock 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 # Input

end # Vedeu

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
vedeu-0.8.0 lib/vedeu/input/key.rb
vedeu-0.6.17 lib/vedeu/input/key.rb
vedeu-0.6.16 lib/vedeu/input/key.rb
vedeu-0.6.15 lib/vedeu/input/key.rb
vedeu-0.6.14 lib/vedeu/input/key.rb
vedeu-0.6.13 lib/vedeu/input/key.rb