Class: CliMiami::A
- Inherits:
-
Object
- Object
- CliMiami::A
- Defined in:
- lib/cli_miami/ask.rb
Constant Summary collapse
- @@prompt =
'>>> '
Class Method Summary collapse
-
.sk(question, options = {}, &block) ⇒ Object
See documentation for CliMiami::S.ay The same options are accepted.
Class Method Details
.sk(question, options = {}, &block) ⇒ Object
See documentation for CliMiami::S.ay The same options are accepted
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/cli_miami/ask.rb', line 13 def self.sk question, = {}, &block # set default options @options = { :readline => false } # merge preset options if .is_a? Symbol @options.merge! CliMiami.presets[] elsif preset = .delete(:preset) @options.merge! CliMiami.presets[preset] end # merge remaining options if .is_a? Hash @options.merge! end CliMiami::S.ay question, @options output = if @options[:readline] Readline.readline(@@prompt).chomp('/') else CliMiami::S.ay @@prompt, :newline => false $stdin.gets end.rstrip # return response if no block is passed if block_given? yield output else return output end end |