Sha256: cc4af498b0b2f3e2dd2cf8a3d81199e9ee4d68b6004f24f3045c814e69ca7648

Contents?: true

Size: 837 Bytes

Versions: 20

Compression:

Stored size: 837 Bytes

Contents

= ANSI::Mixin

The ANSI::Mixin module is design for including into
String-like classes. It will support any class that defines
a #to_s method.

  require 'ansi/mixin'

In this demonstration we will simply include it in the
core String class.

  class ::String
    include ANSI::Mixin
  end

Now all strings will have access to ANSI's style and color
codes via simple method calls.

  "roses".red.assert == "\e[31mroses\e[0m"

  "violets".blue.assert == "\e[34mviolets\e[0m"

  "sugar".italic.assert == "\e[3msugar\e[0m"

The method can be combined, of course.

  "you".italic.bold.assert == "\e[1m\e[3myou\e[0m\e[0m"

The mixin also supports background methods.

  "envy".on_green.assert == "\e[42menvy\e[0m"

And it also supports the combined foreground-on-background 
methods.

  "b&w".white_on_black.assert == "\e[37m\e[40mb&w\e[0m"

Version data entries

20 entries across 20 versions & 5 rubygems

Version Path
arcabouco-0.2.13 vendor/bundle/gems/ansi-1.4.3/demo/05_mixin.rdoc
challah-1.0.0 vendor/bundle/gems/ansi-1.4.3/demo/05_mixin.rdoc
swipe-rails-0.0.5 vendor/bundle/gems/ansi-1.4.3/demo/05_mixin.rdoc
challah-1.0.0.beta3 vendor/bundle/gems/ansi-1.4.3/demo/05_mixin.rdoc
challah-1.0.0.beta2 vendor/bundle/gems/ansi-1.4.3/demo/05_mixin.rdoc
challah-1.0.0.beta vendor/bundle/gems/ansi-1.4.3/demo/05_mixin.rdoc
challah-0.9.1.beta.3 vendor/bundle/gems/ansi-1.4.3/demo/05_mixin.rdoc
challah-0.9.1.beta vendor/bundle/gems/ansi-1.4.3/demo/05_mixin.rdoc
challah-0.9.0 vendor/bundle/gems/ansi-1.4.3/demo/05_mixin.rdoc
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.3/vendor/bundle/gems/ansi-1.4.3/demo/05_mixin.rdoc
challah-0.8.3 vendor/bundle/gems/ansi-1.4.3/demo/05_mixin.rdoc
ansi-1.4.3 demo/05_mixin.rdoc
challah-0.6.1 vendor/bundle/gems/ansi-1.4.2/qed/05_mixin.rdoc
challah-0.6.0 vendor/bundle/gems/ansi-1.4.2/qed/05_mixin.rdoc
ansi-1.4.2 qed/05_mixin.rdoc
ansi-1.4.1 qed/05_mixin.rdoc
ansi-1.4.0 qed/05_mixin.rdoc
ansi-1.3.0 qed/05_mixin.rdoc
ansi-1.2.5 qed/05_mixin.rdoc
ansi-1.2.4 qed/05_mixin.rdoc