Class: Scrubber::Match

Inherits:
Struct
  • Object
show all
Defined in:
lib/scrubber/match.rb,
sig/scrubber_rb.rbs

Overview

One thing the engine found, without the thing itself.

begin and end are character offsets into the string you passed, so text[match.begin...match.end] gives you the raw value back if you really want it. preview is already masked — it exists so you can log "we found an email here" without logging the email.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#beginObject

Returns the value of attribute begin

Returns:

  • (Object)

    the current value of begin



10
11
12
# File 'lib/scrubber/match.rb', line 10

def begin
  @begin
end

#endObject

Returns the value of attribute end

Returns:

  • (Object)

    the current value of end



10
11
12
# File 'lib/scrubber/match.rb', line 10

def end
  @end
end

#previewObject

Returns the value of attribute preview

Returns:

  • (Object)

    the current value of preview



10
11
12
# File 'lib/scrubber/match.rb', line 10

def preview
  @preview
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



10
11
12
# File 'lib/scrubber/match.rb', line 10

def type
  @type
end

Instance Method Details

#inspectObject Also known as: to_s



21
22
23
24
# File 'lib/scrubber/match.rb', line 21

def inspect
  "#<Scrubber::Match type=#{type.inspect} #{self.begin}...#{self.end} " \
    "preview=#{preview.inspect}>"
end

#lengthInteger

Length of the match in characters.

Returns:

  • (Integer)


17
18
19
# File 'lib/scrubber/match.rb', line 17

def length
  self.end - self.begin
end

#to_rangeRange[Integer]

The span as a Range, ready for String#[].

Returns:

  • (Range[Integer])


12
13
14
# File 'lib/scrubber/match.rb', line 12

def to_range
  self.begin...self.end
end