Class: Rugex::File
Instance Method Summary collapse
-
#initialize(file_path, regex_string) ⇒ File
constructor
A new instance of File.
- #to_s ⇒ Object
Constructor Details
#initialize(file_path, regex_string) ⇒ File
Returns a new instance of File.
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_s ⇒ Object
20 |
# File 'lib/rugex/file.rb', line 20 def to_s; @result; end |