Sha256: 9775d5d7aba7d8fcba25bda08ca75cfc72d6cf011b61f37326b9c154aaccd97a

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

require_relative 'lib/cliprompt'

class Myclass
  include Cliprompt

  def initialize
  end

  def askit
    puts '-------------------'
    puts 'numeric default'
    show "what is your age?", 42
    show "what is your size?", 6.2
    puts '-------------------'
    puts 'Free form'
    show "This simply ask for a simple form mandatory thing?"
    show "This simply ask for a simple form mandatory thing?", 'with a default'
    show "This simply ask for a simple form mandatory thing?", default: 'with a default again'
    puts '-------------------'
    puts 'yes/no'
    show 'a boolean?', 'y/N'
    show 'a boolean?', 'yN'
    show 'a boolean?', 'yesno'
    show 'a boolean?', 'yesNo'
    show 'a boolean?', boolean: true
    show 'a boolean?', boolean: true, default: false
    puts '-------------------'
    puts 'a list of choices'
    show 'a list without default?', [22, 33, 44, '55']
    show 'a list with default?', ['22', '33', '=44', '55']
    show 'a list without default?', choices: ['22', '33', '44', '55'], default: 22
    show 'a list with default?', choices: ['22', 33, '=44', '55']
  end

  def guessit
    puts '-------------------'
    showguess 'SOMEVAR', "what is your var?"
    showguess 'SOMEVAR', "what is your var?", 42
    showguess 'SOMEVAR', "what is your var?", boolean: true
    showguess 'SOMEVAR', "what is your var?", [12, 'aa']
  end

  def show(*args)
    it = ask *args
    puts "-- returned #{it.inspect}"
    puts
  end

  def showguess(*args)
    it = guess *args
    puts "-- returned #{it.inspect}"
    puts
  end

end

m = Myclass.new
m.guessit
m.askit

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cliprompt-0.0.3 example.rb