Class: Pipio::FileReader
- Inherits:
-
Object
- Object
- Pipio::FileReader
- Defined in:
- lib/pipio/file_reader.rb
Instance Attribute Summary collapse
-
#first_line ⇒ Object
readonly
Returns the value of attribute first_line.
-
#other_lines ⇒ Object
readonly
Returns the value of attribute other_lines.
Instance Method Summary collapse
-
#initialize(path_to_file, cleaner) ⇒ FileReader
constructor
A new instance of FileReader.
- #read ⇒ Object
Constructor Details
#initialize(path_to_file, cleaner) ⇒ FileReader
Returns a new instance of FileReader.
3 4 5 6 7 8 |
# File 'lib/pipio/file_reader.rb', line 3 def initialize(path_to_file, cleaner) @path_to_file = path_to_file @first_line = '' @other_lines = [] @cleaner = cleaner end |
Instance Attribute Details
#first_line ⇒ Object (readonly)
Returns the value of attribute first_line.
10 11 12 |
# File 'lib/pipio/file_reader.rb', line 10 def first_line @first_line end |
#other_lines ⇒ Object (readonly)
Returns the value of attribute other_lines.
10 11 12 |
# File 'lib/pipio/file_reader.rb', line 10 def other_lines @other_lines end |
Instance Method Details
#read ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pipio/file_reader.rb', line 12 def read if File.exist?(@path_to_file) open(@path_to_file) do |file| @first_line = file.readline.strip @other_lines = file.readlines.map(&:strip) end clean_other_lines end end |