Class: Minitest::UntzLOL

Inherits:
UntzIO
  • Object
show all
Defined in:
lib/minitest/untz_plugin.rb

Constant Summary collapse

PI_3 =

:nodoc:

Math::PI / 3

Constants inherited from UntzIO

Minitest::UntzIO::ESC, Minitest::UntzIO::NND

Instance Attribute Summary

Attributes inherited from UntzIO

#io

Instance Method Summary collapse

Methods inherited from UntzIO

#method_missing, #print, #puts, untz!, untz?

Constructor Details

#initialize(io) ⇒ UntzLOL

:nodoc:



94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/minitest/untz_plugin.rb', line 94

def initialize(io) # :nodoc:
  @colors = (0...(6 * 7)).map { |n|
    n *= 1.0 / 6
    r  = (3 * Math.sin(n           ) + 3).to_i
    g  = (3 * Math.sin(n + 2 * PI_3) + 3).to_i
    b  = (3 * Math.sin(n + 4 * PI_3) + 3).to_i

    36 * r + 6 * g + b + 16
  }

  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Minitest::UntzIO

Instance Method Details

#untz(string) ⇒ Object



107
108
109
110
111
112
113
114
115
116
# File 'lib/minitest/untz_plugin.rb', line 107

def untz(string)
  string = case string
           when '.' then 'untz'
           when 'S' then 'wub'
           else string
           end
  c = @colors[@index % @size]
  @index += 1
  "#{ESC}38;5;#{c}m#{string}#{NND}"
end