Class: MatchData

Inherits:
Object
  • Object
show all
Defined in:
lib/twitter-text/extractor.rb

Overview

Helper functions to return character offsets instead of byte offsets.

Instance Method Summary collapse

Instance Method Details

#char_begin(n) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/twitter-text/extractor.rb', line 29

def char_begin(n)
  if string.respond_to? :codepoints
    self.begin(n)
  else
    string[0, self.begin(n)].char_length
  end
end

#char_end(n) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/twitter-text/extractor.rb', line 37

def char_end(n)
  if string.respond_to? :codepoints
    self.end(n)
  else
    string[0, self.end(n)].char_length
  end
end