Class: Stairs::Util::CLI::Collector

Inherits:
Object
  • Object
show all
Defined in:
lib/stairs/util/cli.rb

Instance Method Summary collapse

Constructor Details

#initialize(prompt, options = {}, &block) ⇒ Collector

Returns a new instance of Collector.



19
20
21
22
23
# File 'lib/stairs/util/cli.rb', line 19

def initialize(prompt, options={}, &block)
  @prompt = prompt
  @options = options.reverse_merge required: true
  @validator = block
end

Instance Method Details

#runObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/stairs/util/cli.rb', line 25

def run
  times, value = 0, nil

  until valid?(value, times)
    value = CLI.get(prompt.blue)
    times += 1
  end

  value
end