Module: Ergane::Util::Formatting
Constant Summary collapse
- COLORS =
%i[light_red light_yellow light_green light_blue light_cyan light_magenta].freeze
Instance Method Summary collapse
- #color_cycle ⇒ Object
- #colorize_list(items) ⇒ Object
- #next_color ⇒ Object
- #rainbow(string, delimiter = " ") ⇒ Object
- #reset_colors! ⇒ Object
Instance Method Details
#color_cycle ⇒ Object
10 11 12 |
# File 'lib/ergane/util/formatting.rb', line 10 def color_cycle @color_cycle ||= COLORS.cycle end |
#colorize_list(items) ⇒ Object
26 27 28 |
# File 'lib/ergane/util/formatting.rb', line 26 def colorize_list(items) items.map { |item| item.to_s.send(next_color) } end |
#next_color ⇒ Object
14 15 16 |
# File 'lib/ergane/util/formatting.rb', line 14 def next_color color_cycle.next end |
#rainbow(string, delimiter = " ") ⇒ Object
22 23 24 |
# File 'lib/ergane/util/formatting.rb', line 22 def rainbow(string, delimiter = " ") string.split(delimiter).map { |word| word.to_s.send(next_color) }.join(delimiter) end |