class MatchData

Public Instance Methods

line_index() click to toggle source

@return [Fixnum]

# File lib/epuber/ruby_extensions/match_data.rb, line 25
def line_index
  pre_match_lines.length - 1
end
line_number() click to toggle source

@return [Fixnum]

# File lib/epuber/ruby_extensions/match_data.rb, line 17
def line_number
  n = pre_match_lines.length
  n += 1 if n == 0 # it can't be zero, this happens only when the match is at the beginning of file or string
  n
end
matched_line() click to toggle source

@return [String]

# File lib/epuber/ruby_extensions/match_data.rb, line 31
def matched_line
  (pre_match_lines.last || '') + matched_string + (post_match_lines.first || '')
end
matched_string() click to toggle source

@return [String]

# File lib/epuber/ruby_extensions/match_data.rb, line 37
def matched_string
  self[0]
end
post_match_lines() click to toggle source

@return [Array<String>]

# File lib/epuber/ruby_extensions/match_data.rb, line 11
def post_match_lines
  @post_match_lines ||= post_match.split(/\r?\n/)
end
pre_match_lines() click to toggle source

@return [Array<String>]

# File lib/epuber/ruby_extensions/match_data.rb, line 5
def pre_match_lines
  @pre_match_lines ||= pre_match.split(/\r?\n/)
end