Module: Battleroom::Printable
- Included in:
- BattleroomMachinery
- Defined in:
- lib/battleroom/helpers/printable.rb
Constant Summary collapse
- CONGRATULATIONS =
[ 'Lovely work, my friend!', 'Beautiful!', 'Lovely!', 'Splendid!', 'Awesome.', 'Stand up job, my friend.', 'Nailed it.', 'Nice job! Keep it rolling!', 'Capital work, battlestar!', 'Exemplary work!', 'Yeah!', 'Roll on.', 'Bullseye!', 'Woo!', 'Let it ride!', 'Touchdown!', "You're on your way!", "You're making a prosperous go of this programming thing.", ]
Instance Method Summary collapse
- #battleprint(string) ⇒ Object
- #codify(str) ⇒ Object
- #colorized_arithmetic_operator_list ⇒ Object
- #dynamic_word_wrap(string) ⇒ Object
- #format_class_for_output(klass) ⇒ Object
- #format_value_for_stdout_and_eval(object) ⇒ Object
- #indent_all_lines_for_stdout(string_to_indent) ⇒ Object
- #print_congratulation ⇒ Object
- #print_menu_options ⇒ Object
- #random_congratulation ⇒ Object
Instance Method Details
#battleprint(string) ⇒ Object
50 51 52 |
# File 'lib/battleroom/helpers/printable.rb', line 50 def battleprint(string) puts dynamic_word_wrap(string) end |
#codify(str) ⇒ Object
73 74 75 |
# File 'lib/battleroom/helpers/printable.rb', line 73 def codify(str) str.black.on_light_white end |
#colorized_arithmetic_operator_list ⇒ Object
77 78 79 |
# File 'lib/battleroom/helpers/printable.rb', line 77 def colorized_arithmetic_operator_list codify(" + ") + ", ".blue + codify(" - ") + ", ".blue + codify(" * ") + ", or ".blue + codify(" / ") end |
#dynamic_word_wrap(string) ⇒ Object
46 47 48 |
# File 'lib/battleroom/helpers/printable.rb', line 46 def dynamic_word_wrap(string) string.wrap(150) end |
#format_class_for_output(klass) ⇒ Object
68 69 70 71 |
# File 'lib/battleroom/helpers/printable.rb', line 68 def format_class_for_output(klass) return 'Boolean' if klass.to_s.match /(TrueClass|FalseClass)/ klass.to_s end |
#format_value_for_stdout_and_eval(object) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/battleroom/helpers/printable.rb', line 54 def format_value_for_stdout_and_eval(object) case object.class.to_s when 'String' if object.include?("'") '"' + object + '"' else "'#{object}'" end when 'Symbol' then return ":#{object}" else object.to_s end end |
#indent_all_lines_for_stdout(string_to_indent) ⇒ Object
42 43 44 |
# File 'lib/battleroom/helpers/printable.rb', line 42 def indent_all_lines_for_stdout(string_to_indent) string_to_indent.gsub(/^.*/) { |match| "\t" + match } end |
#print_congratulation ⇒ Object
38 39 40 |
# File 'lib/battleroom/helpers/printable.rb', line 38 def print_congratulation battleprint "\n#{random_congratulation}\n".green end |
#print_menu_options ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/battleroom/helpers/printable.rb', line 25 def battleprint ' What would you like to work on?'.blue battleprint '1. Working with Variables' battleprint '2. Accessing Values in Arrays and Hashes' battleprint '3. Adding Values to Arrays and Hashes' battleprint '4. Working with Methods' battleprint "Q. Quit\r\n\n" end |
#random_congratulation ⇒ Object
34 35 36 |
# File 'lib/battleroom/helpers/printable.rb', line 34 def random_congratulation CONGRATULATIONS.sample end |