Sha256: 17a0b3c9b50ee8eae2b8e3a59af51bb04a352d84181170e6e63f3a23f95a2e1a

Contents?: true

Size: 726 Bytes

Versions: 3

Compression:

Stored size: 726 Bytes

Contents

module Vedeu

  module Input

    class Raw

      # @see Vedeu::Input::Raw#initialize
      def self.read
        new.read
      end

      # Returns a new instance of Vedeu::Input::Raw.
      #
      # @return [Vedeu::Input::Raw]
      def initialize; end

      # @return [String]
      def read
        keys = console.getch

        if keys.ord == Vedeu::ESCAPE_KEY_CODE
          keys << console.read_nonblock(4) rescue nil
          keys << console.read_nonblock(3) rescue nil
          keys << console.read_nonblock(2) rescue nil
        end

        keys
      end

      private

      # @return [IO]
      def console
        @console ||= Vedeu::Terminal.console
      end

    end # Raw

  end # Input

end # Vedeu

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vedeu-0.6.68 lib/vedeu/input/raw.rb
vedeu-0.6.67 lib/vedeu/input/raw.rb
vedeu-0.6.66 lib/vedeu/input/raw.rb