Method: String::Mask#-

Defined in:
lib/strmask.rb

#-(other) ⇒ Object

Mask subtraction. Where the characters are the same, the result is “empty”, where they differ the result reflects the last string.

  "abc..123"      "ab..789."
- "ab..789."    - "abc..123"
  ----------      ----------
  "....789."      "..c..123"


75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/strmask.rb', line 75

def -(other)
  other = convert(other)
  i = 0
  o = ''
  while i < to_str.size
    if to_str[i,1] == other[i,1]
      o << ESC
    else
      o << other[i,1]
    end
    i += 1
  end
  self.class.new(o)
end