class FlashKick::QuestionHelper
Public Class Methods
boolean_question(question, key, default=nil)
click to toggle source
# File lib/generators/flash_kick/lib/question_helper.rb, line 42 def self.boolean_question(question, key, default=nil) answer = Thor.new.yes?(question) FlashKick::VariableStore.add_variable(key, answer == true ? answer : false) end
question(type, &block)
click to toggle source
# File lib/generators/flash_kick/lib/question_helper.rb, line 11 def self.question(type, &block) question_hash = block.call @@required = question_hash[:required] default = question_hash[:default] key = question_hash.keys[0] question = "#{question_hash[key]}:" question_divider(default) case type when :string string_question(question, key, default) when :boolean boolean_question(question, key, default) end end
question_divider(value=nil)
click to toggle source
# File lib/generators/flash_kick/lib/question_helper.rb, line 47 def self.question_divider(value=nil) puts '-' * 100 @shell.say("Default: #{value}", :green) unless value.nil? end
string_question(question, key, default=nil)
click to toggle source
# File lib/generators/flash_kick/lib/question_helper.rb, line 28 def self.string_question(question, key, default=nil) if @@required == true answer = '' until answer != '' answer = Thor.new.ask(question) FlashKick::VariableStore.add_variable(key, answer.empty? ? default : answer) @shell.say("Answer required, but you can always change it later!!!\n\n", :yellow) if answer == '' end else answer = Thor.new.ask(question) FlashKick::VariableStore.add_variable(key, answer.empty? ? default : answer) end end