Sha256: 5a414321790e484afc3f97e9a8078e97b268b7616706a5bfc60afc8f96b39db5

Contents?: true

Size: 847 Bytes

Versions: 5

Compression:

Stored size: 847 Bytes

Contents

# encoding: utf-8

require 'io/console'

module TTY
  class Prompt
    class Reader
      class Mode
        # Initialize a Terminal
        #
        # @api public
        def initialize(input = $stdin)
          @input = input
        end

        # Echo given block
        #
        # @param [Boolean] is_on
        #
        # @api public
        def echo(is_on = true, &block)
          previous = @input.echo?
          @input.echo = is_on
          yield
        ensure
          @input.echo = previous
        end

        # Use raw mode in the given block
        #
        # @param [Boolean] is_on
        #
        # @api public
        def raw(is_on = true, &block)
          if is_on
            @input.raw(&block)
          else
            yield
          end
        end
      end # Mode
    end # Reader
  end # Prompt
end # TTY

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tty-prompt-0.10.1 lib/tty/prompt/reader/mode.rb
tty-prompt-0.10.0 lib/tty/prompt/reader/mode.rb
tty-prompt-0.9.0 lib/tty/prompt/reader/mode.rb
tty-prompt-0.8.0 lib/tty/prompt/reader/mode.rb
tty-prompt-0.7.1 lib/tty/prompt/reader/mode.rb