Class: Rubygrep::GrepManager
- Inherits:
-
Object
- Object
- Rubygrep::GrepManager
- Defined in:
- lib/rubygrep/grep_manager.rb
Instance Attribute Summary collapse
-
#file_reader ⇒ Object
readonly
Returns the value of attribute file_reader.
-
#matcher ⇒ Object
readonly
Returns the value of attribute matcher.
-
#outputter ⇒ Object
readonly
Returns the value of attribute outputter.
Instance Method Summary collapse
-
#initialize(options) ⇒ GrepManager
constructor
A new instance of GrepManager.
- #run ⇒ Object
Constructor Details
#initialize(options) ⇒ GrepManager
Returns a new instance of GrepManager.
5 6 7 8 9 10 |
# File 'lib/rubygrep/grep_manager.rb', line 5 def initialize() @file_reader = FileReader.new(.file_names, .) .set_multi_file_mode if @file_reader.has_several_files? @matcher = Matcher.new(.expression, .) @outputter = Outputter.new(.) end |
Instance Attribute Details
#file_reader ⇒ Object (readonly)
Returns the value of attribute file_reader.
3 4 5 |
# File 'lib/rubygrep/grep_manager.rb', line 3 def file_reader @file_reader end |
#matcher ⇒ Object (readonly)
Returns the value of attribute matcher.
3 4 5 |
# File 'lib/rubygrep/grep_manager.rb', line 3 def matcher @matcher end |
#outputter ⇒ Object (readonly)
Returns the value of attribute outputter.
3 4 5 |
# File 'lib/rubygrep/grep_manager.rb', line 3 def outputter @outputter end |
Instance Method Details
#run ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rubygrep/grep_manager.rb', line 12 def run file_reader.each_line do |line_data| begin match_data = matcher.matches?(line_data) if match_data outputter.out(match_data, line_data) end rescue Exception => e file_reader.next_file! outputter.error(e., line_data) end end end |