class Expect::Match

Attributes

buffer[R]
success[R]

Public Class Methods

new(expression, buffer) click to toggle source
# File lib/expect/match.rb, line 5
def initialize(expression, buffer)
  @expression = expression
  @buffer     = buffer
  @matches    = @buffer.match(@expression)
end

Public Instance Methods

exact_match_string() click to toggle source

returns the first capture from the match

# File lib/expect/match.rb, line 12
def exact_match_string
  @matches.nil? ? nil : @matches[0]
end
expr_substring_to_match() click to toggle source
# File lib/expect/match.rb, line 16
def expr_substring_to_match
  Regexp.new(".*?#{@expression.source}", @expression.options | Regexp::MULTILINE)
end
nil?() click to toggle source

true if there were no matches

# File lib/expect/match.rb, line 21
def nil?
  @matches.nil?
end
remainder()
Alias for: substring_remainder
substring_remainder() click to toggle source

returns the contents of the buffer following the first match

# File lib/expect/match.rb, line 32
def substring_remainder
  if @matches.nil?
    @buffer
  else
    start_index = substring_up_to_match.length
    @buffer[start_index..-1]
  end
end
Also aliased as: remainder
substring_up_to_match() click to toggle source

returns the contents of the buffer up to the match

# File lib/expect/match.rb, line 26
def substring_up_to_match
  @matches.nil? ? nil : @buffer.match(expr_substring_to_match)[0]
end
Also aliased as: to_s
to_s()