class Cannonbol::MatchString

Attributes

captured[R]
match_end[R]
match_start[R]

Public Class Methods

new(string, match_start, match_end, captured) click to toggle source
Calls superclass method
# File lib/cannonbol/cannonbol.rb, line 11
def initialize(string, match_start, match_end, captured)
  @cannonbol_string = string
  @match_start = match_start
  @match_end = match_end
  @captured = captured.dup
  super(@match_end < 0 ? "" : string[@match_start..@match_end])
end

Public Instance Methods

replace_match_with(s) click to toggle source
# File lib/cannonbol/cannonbol.rb, line 19
def replace_match_with(s)
  before_match = ""
  before_match = @cannonbol_string[0..@match_start-1] if @match_start > 0
  after_match = @cannonbol_string[@match_end+1..-1] || ""
  before_match + s + after_match
end