Class: Rugex::File

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

Instance Method Summary collapse

Constructor Details

#initialize(file_path, regex_string) ⇒ File

Returns a new instance of File.

Raises:



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rugex/file.rb', line 7

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

  @regex = Regexp.new(regex_string)

  file = ::File.open(file_path)
  @result = file.lines.inject '' do |colored_text, line|
    @text = line
    colored_text << colorize_text
  end
  file.close
end

Instance Method Details

#to_sObject



20
# File 'lib/rugex/file.rb', line 20

def to_s; @result; end