class MatchData
Public Instance Methods
line_index()
click to toggle source
@return [Fixnum]
# File lib/epuber/ruby_extensions/match_data.rb, line 26 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 18 def line_number n = pre_match_lines.length n += 1 if n.zero? # 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 32 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 38 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 12 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 6 def pre_match_lines @pre_match_lines ||= pre_match.split(/\r?\n/) end