Class: Nabokov::Informator
- Inherits:
-
Object
- Object
- Nabokov::Informator
- Defined in:
- lib/nabokov/helpers/informator.rb
Overview
This class is heavily based on the Interviewer class from the Danger gem The original link is github.com/danger/danger/blob/master/lib/danger/commands/init_helpers/interviewer.rb
Instance Attribute Summary collapse
-
#no_waiting ⇒ Object
Returns the value of attribute no_waiting.
-
#ui ⇒ Object
Returns the value of attribute ui.
Instance Method Summary collapse
- #ask_with_answers(question, possible_answers) ⇒ Object
- #error(message) ⇒ Object
- #important(message) ⇒ Object
- #inform(message) ⇒ Object
-
#initialize(cork_board) ⇒ Informator
constructor
A new instance of Informator.
- #say(message) ⇒ Object
- #show_prompt ⇒ Object
- #wait_for_return ⇒ Object
- #warn(message) ⇒ Object
Constructor Details
#initialize(cork_board) ⇒ Informator
Returns a new instance of Informator.
9 10 11 |
# File 'lib/nabokov/helpers/informator.rb', line 9 def initialize(cork_board) @ui = cork_board end |
Instance Attribute Details
#no_waiting ⇒ Object
Returns the value of attribute no_waiting.
7 8 9 |
# File 'lib/nabokov/helpers/informator.rb', line 7 def no_waiting @no_waiting end |
#ui ⇒ Object
Returns the value of attribute ui.
7 8 9 |
# File 'lib/nabokov/helpers/informator.rb', line 7 def ui @ui end |
Instance Method Details
#ask_with_answers(question, possible_answers) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/nabokov/helpers/informator.rb', line 46 def ask_with_answers(question, possible_answers) ui.print("\n#{question}? [") print_possible_answers(possible_answers) answer = "" loop do show_prompt answer = read_answer(possible_answers) break if possible_answers.map(&:downcase).include? answer ui.print "\nPossible answers are [" print_possible_answers(possible_answers) end answer end |
#error(message) ⇒ Object
36 37 38 |
# File 'lib/nabokov/helpers/informator.rb', line 36 def error() ui.puts(.red) end |
#important(message) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/nabokov/helpers/informator.rb', line 25 def important() i = .length + 8 inform("-" * i) inform("--- " + + " ---") inform("-" * i) end |
#inform(message) ⇒ Object
21 22 23 |
# File 'lib/nabokov/helpers/informator.rb', line 21 def inform() ui.puts(.green) end |
#say(message) ⇒ Object
17 18 19 |
# File 'lib/nabokov/helpers/informator.rb', line 17 def say() ui.puts() end |
#show_prompt ⇒ Object
13 14 15 |
# File 'lib/nabokov/helpers/informator.rb', line 13 def show_prompt ui.print("> ".bold.green) end |
#wait_for_return ⇒ Object
40 41 42 43 44 |
# File 'lib/nabokov/helpers/informator.rb', line 40 def wait_for_return STDOUT.flush STDIN.gets unless @no_waiting ui.puts end |
#warn(message) ⇒ Object
32 33 34 |
# File 'lib/nabokov/helpers/informator.rb', line 32 def warn() ui.puts(.yellow) end |