Class: FileProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/rforward/file_processor.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filepath, line_processor) ⇒ FileProcessor

Returns a new instance of FileProcessor.



4
5
6
# File 'lib/rforward/file_processor.rb', line 4

def initialize filepath, line_processor
  @filepath, @line_processor = filepath, line_processor
end

Instance Attribute Details

#filepathObject

Returns the value of attribute filepath.



2
3
4
# File 'lib/rforward/file_processor.rb', line 2

def filepath
  @filepath
end

#line_processorObject

Returns the value of attribute line_processor.



2
3
4
# File 'lib/rforward/file_processor.rb', line 2

def line_processor
  @line_processor
end

Class Method Details

.call(filepath) ⇒ Object



14
15
16
17
# File 'lib/rforward/file_processor.rb', line 14

def self.call filepath
  processor = FileProcessor.new filepath, FFluentdLine.new
  processor.call
end

Instance Method Details

#callObject



8
9
10
11
12
# File 'lib/rforward/file_processor.rb', line 8

def call
  File.readlines(filepath).each do |line|
    line_processor.call line
  end
end