QED.rdoc in ansi-1.4.1 vs QED.rdoc in ansi-1.4.2
- old
+ new
@@ -46,35 +46,22 @@
The ANSI::Code module supports most standard ANSI codes, though
not all platforms support every code, so YMMV.
-= ANSI::BBCode
+= String Extensions
-The BBCode module provides methods for converting between
-BBCodes, basic HTML and ANSI codes.
+In addition the library offers an extension to String class
+called #ansi, which allows some of the ANSI::Code methods
+to be called in a more object-oriented fashion.
- require 'ansi/bbcode'
+ require 'ansi/core'
-BBCodes are color and style codes in square brackets, quite
-popular with on line forums.
+ str = "Hello".ansi(:red) + "World".ansi(:blue)
+ str.assert == "\e[31mHello\e[0m\e[34mWorld\e[0m"
- bbcode = "this is [COLOR=red]red[/COLOR], this is [B]bold[/B]"
-We can convert this to ANSI code simply enough:
-
- ansi = ANSI::BBCode.bbcode_to_ansi(bbcode)
-
- ansi.assert == "this is \e[0;31mred\e[0m, this is \e[1mbold\e[0m\n"
-
-In addition the BBCode module supports conversion to simple HTML.
-
- html = ANSI::BBCode.bbcode_to_html(bbcode)
-
- html.assert == "this is <font color=\"red\">red</font>, this is <strong>bold</strong><br />\n"
-
-
= ANSI::Logger
Require the ANSI::Logger library.
require 'ansi/logger'
@@ -382,17 +369,87 @@
| 50 | 40 | 20 |
+----+----+----+
-= String Extensions
+= ANSI::Diff
-In addition the library offers an extension to String class
-called #ansi, which allows some of the ANSI::Code methods
-to be called in a more object-oriented fashion.
+ require 'ansi/diff'
- require 'ansi/core'
+ a = 'abcYefg'
+ b = 'abcXefg'
- str = "Hello".ansi(:red) + "World".ansi(:blue)
- str.assert == "\e[31mHello\e[0m\e[34mWorld\e[0m"
+ diff = ANSI::Diff.new(a,b)
+
+ diff.to_s.assert == "\e[31mabc\e[0m\e[33mYefg\e[0m\n\e[31mabc\e[0mXefg"
+
+Try another.
+
+ a = 'abc'
+ b = 'abcdef'
+
+ diff = ANSI::Diff.new(a,b)
+
+ diff.to_s.assert == "\e[31mabc\e[0m\n\e[31mabc\e[0mdef"
+
+And another.
+
+ a = 'abcXXXghi'
+ b = 'abcdefghi'
+
+ diff = ANSI::Diff.new(a,b)
+
+ diff.to_s.assert == "\e[31mabc\e[0m\e[33mXXXghi\e[0m\n\e[31mabc\e[0mdefghi"
+
+And another.
+
+ a = 'abcXXXdefghi'
+ b = 'abcdefghi'
+
+ diff = ANSI::Diff.new(a,b)
+
+ diff.to_s.assert == "\e[31mabc\e[0m\e[33mXXX\e[0m\e[35mdefghi\e[0m\n\e[31mabc\e[0m\e[35mdefghi\e[0m"
+
+Comparison that is mostly different.
+
+ a = 'abcpppz123'
+ b = 'abcxyzzz43'
+
+ diff = ANSI::Diff.new(a,b)
+
+ diff.to_s.assert == "\e[31mabc\e[0m\e[33mpppz123\e[0m\n\e[31mabc\e[0mxyzzz43"
+
+
+= ANSI::BBCode
+
+The BBCode module provides methods for converting between
+BBCodes, basic HTML and ANSI codes.
+
+ require 'ansi/bbcode'
+
+BBCodes are color and style codes in square brackets, quite
+popular with on line forums.
+
+ bbcode = "this is [COLOR=red]red[/COLOR], this is [B]bold[/B]"
+
+We can convert this to ANSI code simply enough:
+
+ ansi = ANSI::BBCode.bbcode_to_ansi(bbcode)
+
+ ansi.assert == "this is \e[0;31mred\e[0m, this is \e[1mbold\e[0m\n"
+
+In addition the BBCode module supports conversion to simple HTML.
+
+ html = ANSI::BBCode.bbcode_to_html(bbcode)
+
+ html.assert == "this is <font color=\"red\">red</font>, this is <strong>bold</strong><br />\n"
+
+
+= ANSI::Terminal
+
+We should be ables to get the terminal width via the `terminal_width` method.
+
+ width = ANSI::Terminal.terminal_width
+
+ Fixnum.assert === width