class MatchData

Public Instance Methods

byteoffset(n) click to toggle source
# File lib/backports/3.2.0/match_data/byteoffset.rb, line 3
def byteoffset(n)
  if (char_start_offset = self.begin(n))
    char_end_offset = self.end(n)
    [string[0, char_start_offset].bytesize, string[0, char_end_offset].bytesize]
  else
    [nil, nil]
  end
end
match(index) click to toggle source
# File lib/backports/3.1.0/match_data/match.rb, line 2
def match(index)
  self[index]
end
match_length(index) click to toggle source
# File lib/backports/3.1.0/match_data/match_length.rb, line 2
def match_length(index)
  m = self[index]
  m && m.length
end
named_captures_with_symbolize_option(symbolize_keys: false) click to toggle source
# File lib/backports/3.3.0/match_data/named_captures.rb, line 5
def named_captures_with_symbolize_option(symbolize_keys: false)
  captures = named_captures_without_symbolize_option
  captures.transform_keys!(&:to_sym) if symbolize_keys
  captures
end