Sha256: 666c0009d271831c5a1d2dbb395a129172223869a9a6f4eeb8de42d0b35cacd0

Contents?: true

Size: 751 Bytes

Versions: 1

Compression:

Stored size: 751 Bytes

Contents

require 'vk'
require 'active_support/concern'

module Vk
  begin
    require 'tty-prompt'
    Prompt = TTY::Prompt
  rescue LoadError
    class Prompt
      # @param [String] message
      # @param [Hash] _options
      def say(message = '', _options = {})
        puts(message)
      end

      def ask(message = '', *_args, &_block)
        print(message << ' ')
        gets.chomp
      end
    end
  end

  module PromptExtension
    extend ActiveSupport::Concern

    module ClassMethods
      # @return [TTY::Prompt]
      def prompt
        @prompt ||= Prompt.new
      end
      attr_writer :prompt
    end

    private

    # @return [TTY::Prompt]
    def prompt
      @prompt ||= self.class.prompt
    end

    attr_writer :prompt
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vk-0.6.5.53 lib/vk/prompt.rb