Sha256: 82a77615323ef118e665b14c31cd93a8ec671f0e18753b47535dd10436cd399a
Contents?: true
Size: 1.02 KB
Versions: 3
Compression:
Stored size: 1.02 KB
Contents
# encoding: utf-8 ## lib/console/string.rb -- include Console methods into String ## Author: William Morgan (mailto: wmorgan-ruby-console@masanjin.net) ## Copyright: Copyright 2010 William Morgan ## License: same terms as Ruby itself require 'console' ## reopen the String class and add #display_width and ## #display_slice methods directly to strings. ## ## If you include "console/string", you can call ## "能吞a".display_width ## instead of ## Console.display_width "能吞a" ## ## and ## ## "能吞a".display_slice 0, 2 ## instead of ## Console.display_slice "能吞a", 0, 2 ## class String ## Returns the display width of the string. See Console.display_width for details. def display_width; Console.display_width self end ## Returns a substring according to display-based start and offset values. See ## Console.display_slice for what this means. ## ## :call-seq: ## display_slice(start, offset=1, pad_string=" ") ## ## (rdoc fail) def display_slice(*a); Console.display_slice self, *a end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
console-0.5 | lib/console/string.rb |
console-0.4 | lib/console/string.rb |
console-0.3 | lib/console/string.rb |