Module: Interactive
- Included in:
- NonEmptyOptions
- Defined in:
- lib/interactive/option.rb,
lib/interactive/options.rb,
lib/interactive/version.rb,
lib/interactive/question.rb,
lib/interactive/response.rb,
lib/interactive/options_shortcuts.rb
Defined Under Namespace
Classes: EmptyOptions, HashNumberedOption, NonEmptyOptions, OptionsShortcuts, Question, ResponseWithArgs, ResponseWithNoArgs, TabularOptions, WholeNumberOption, WordOption
Constant Summary
collapse
- VERSION =
"0.6.2"
Class Method Summary
collapse
Class Method Details
.Option(option) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/interactive/option.rb', line 6
def Option(option)
if option.respond_to?(:to_hash)
@option = HashNumberedOption.new(option)
elsif option.to_s.match(/^\d+$/)
@option = WholeNumberOption.new(option)
else
@option = WordOption.new(option)
end
@option
end
|
.Options(options = [], columns = []) ⇒ Object
6
7
8
9
10
11
12
13
14
|
# File 'lib/interactive/options.rb', line 6
def Options(options=[], columns=[])
if options.empty?
EmptyOptions.new([])
elsif Array(columns).any?
TabularOptions.new(options, columns)
else
NonEmptyOptions.new(options)
end
end
|
.Response(*args) ⇒ Object
6
7
8
9
|
# File 'lib/interactive/response.rb', line 6
def Response(*args)
args = Array(args).flatten
args.empty? ? ResponseWithNoArgs.new(args) : ResponseWithArgs.new(args)
end
|