Sha256: b1bc6476e38e9be17cfee778b5cdb3c7842ee64ff8dae25d38f7c49ad2ac5c21

Contents?: true

Size: 478 Bytes

Versions: 8

Compression:

Stored size: 478 Bytes

Contents

module Pork
  module Rainbows
    def case_pass msg='.'
      @rainbows ||= 0
      io.print( color256(rainbows(@rainbows)){msg} )
      @rainbows  += 1
    end

    private
    def color256 rgb
      "\e[38;5;#{rgb}m#{yield}\e[0m"
    end

    def rainbows i
      n = (i%42) / 6.0
      r = Math.sin(n + 0*Math::PI/3) * 3 + 3
      g = Math.sin(n + 2*Math::PI/3) * 3 + 3
      b = Math.sin(n + 4*Math::PI/3) * 3 + 3
      16 + 36*r.to_i + 6*g.to_i + b.to_i
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pork-1.3.1 lib/pork/extra/rainbows.rb
pork-1.3.0 lib/pork/extra/rainbows.rb
pork-1.2.4 lib/pork/extra/rainbows.rb
pork-1.2.3 lib/pork/extra/rainbows.rb
pork-1.2.2 lib/pork/extra/rainbows.rb
pork-1.2.1 lib/pork/extra/rainbows.rb
pork-1.2.0 lib/pork/extra/rainbows.rb
pork-1.1.3 lib/pork/extra/rainbows.rb