Sha256: df6e5b6d1751809ee4ccf990189ae9a2b0b9130673061b091fb41ad92d802f04

Contents?: true

Size: 390 Bytes

Versions: 6

Compression:

Stored size: 390 Bytes

Contents

require 'highline/import'

module Prompt

  def Prompt.yesno(prompt = 'Continue?', default = false)
    a = ''
    s = default ? '[Y/n/s]' : '[y/N/s]'
    d = default ? 'y' : 'n'
    until %w[y n s].include? a
      a = ask("#{prompt} #{s} ") { |q| q.limit = 1; q.case = :downcase }
      a = d if a.length == 0
    end
    if a == 'y'; true elsif a == 's'; 'skip' else false end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
propre-0.1.1 lib/propre/prompt.rb
propre-0.1.0 lib/propre/prompt.rb
propre-0.0.8 lib/propre/prompt.rb
propre-0.0.7 lib/propre/prompt.rb
propre-0.0.6 lib/propre/prompt.rb
propre-0.0.5 lib/propre/prompt.rb