This project is retired.
String::Mask is now part of Ruby Facets, since Facets 4.2.0 (2026-11): require 'facets/string/mask' for String::Mask and String#mask, with the same operators. Facets’ version differs in a few ways: masks of different lengths combine, a mask is equal only to another mask (compare mask.to_s with a string), and it works with frozen string literals.
This repository preserves Strmask, last released as 0.3.2 in 2011. It is no longer maintained.
<img src=“http://travis-ci.org/rubyworks/strmask.png” />
Mask provides a string utility to manipulate strings in logicomathematical manner, ie. add, subtract, xor, etc.
Mask objects can be created explicitly via #new.
m1 = String::Mask.new("abc..123", '.') m2 = String::Mask.new("ab..789.", '.') m1 - m2 #=> "....789."
But the String#mask extension is much easier to use.
m1 = "abc..123".mask('.') m2 = "ab..789.".mask('.') m1 * m2 #=> "ab..789."
The second operand can be a normal String. Mask will assume it repesents another mask akin to the first.
"abc..123".mask('.') + "ab..789." #=> "abc.7893"
To install with RubyGems simply open a console and type:
$ gem install strmask
Copyright © 2009 Thomas Sawyer, Rubyworks
This program is ditributed unser the terms of the FreeBSD license.
See the NOTICE.rdoc file for details.