Class: Rugex::String

Inherits:
Object
  • Object
show all
Includes:
Print
Defined in:
lib/rugex/string.rb

Instance Method Summary collapse

Constructor Details

#initialize(text, regex_string) ⇒ String

Returns a new instance of String.

Raises:



7
8
9
10
11
12
# File 'lib/rugex/string.rb', line 7

def initialize(text, regex_string)
  raise EmptyRegexError if regex_string.empty?

  @text, @regex = text, Regexp.new(regex_string)
  @result = (@text =~ @regex) == nil ? '(no matches)' : colorize_text
end

Instance Method Details

#to_sObject



14
# File 'lib/rugex/string.rb', line 14

def to_s; @result; end