Sha256: 3358643e442f136e4b64394b2a294c5956806584717078e3ffb454da2a834923

Contents?: true

Size: 520 Bytes

Versions: 19

Compression:

Stored size: 520 Bytes

Contents

module Vpsb
  module AskSupport
    def ask(&block)
      yield if block
      STDIN.gets.chomp
    end

    def ask_to_confirm(question, &block)
      answer = ask { puts "#{question} y[es]/n[o]?" }
      cond = (answer[0].to_s.downcase == 'y')

      yield cond if block

      cond
    end

    def ask_loop(condition = nil, &block)
      condition ||= proc { |res| !res.strip.empty? }

      begin
        yield if block
        res = STDIN.gets.chomp
      end until condition.call(res)
      res
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
vpsb-1.1.8 lib/vpsb/ask_support.rb
vpsb-1.1.7 lib/vpsb/ask_support.rb
vpsb-1.1.6 lib/vpsb/ask_support.rb
vpsb-1.1.5 lib/vpsb/ask_support.rb
vpsb-1.1.4 lib/vpsb/ask_support.rb
vpsb-1.1.3 lib/vpsb/ask_support.rb
vpsb-1.1.2 lib/vpsb/ask_support.rb
vpsb-1.1.1 lib/vpsb/ask_support.rb
vpsb-1.1.0 lib/vpsb/ask_support.rb
vpsb-1.0.9 lib/vpsb/ask_support.rb
vpsb-1.0.8 lib/vpsb/ask_support.rb
vpsb-1.0.7 lib/vpsb/ask_support.rb
vpsb-1.0.6 lib/vpsb/ask_support.rb
vpsb-1.0.5 lib/vpsb/ask_support.rb
vpsb-1.0.4 lib/vpsb/ask_support.rb
vpsb-1.0.3 lib/vpsb/ask_support.rb
vpsb-1.0.2 lib/vpsb/ask_support.rb
vpsb-1.0.1 lib/vpsb/ask_support.rb
vpsb-1.0.0 lib/vpsb/ask_support.rb