Class: Minitest::PrideLOL
- Defined in:
- lib/minitest/pride_plugin.rb
Overview
If you thought the PrideIO was colorful…
(Inspired by lolcat, but with clean math)
Constant Summary collapse
- PI_3 =
:nodoc:
Math::PI / 3
Constants inherited from PrideIO
Minitest::PrideIO::ESC, Minitest::PrideIO::NND
Instance Attribute Summary
Attributes inherited from PrideIO
Instance Method Summary collapse
-
#initialize(io) ⇒ PrideLOL
constructor
:nodoc:.
-
#pride(string) ⇒ Object
Make the string even more colorful.
Methods inherited from PrideIO
#method_missing, pride!, pride?, #print, #puts
Constructor Details
#initialize(io) ⇒ PrideLOL
:nodoc:
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/minitest/pride_plugin.rb', line 105 def initialize io # :nodoc: # walk red, green, and blue around a circle separated by equal thirds. # # To visualize, type this into wolfram-alpha: # # plot (3*sin(x)+3), (3*sin(x+2*pi/3)+3), (3*sin(x+4*pi/3)+3) @colors = Array.new(6 * 7) { |n| n *= 1.0 / 3 r = (3 * Math.sin(n ) + 3).to_i g = (3 * Math.sin(n + 4 * PI_3) + 3).to_i b = (3 * Math.sin(n + 2 * PI_3) + 3).to_i # Then we take rgb and encode them in a single number using # base 6, shifted by 16 for the base 16 ansi colors. 36 * r + 6 * g + b + 16 }.rotate(4) # puts "red" first super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Minitest::PrideIO