Class: TestGem::MyFile
- Inherits:
-
Object
- Object
- TestGem::MyFile
- Defined in:
- lib/test_gem/myfile.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(file_location) ⇒ MyFile
constructor
A new instance of MyFile.
Constructor Details
#initialize(file_location) ⇒ MyFile
Returns a new instance of MyFile.
4 5 6 |
# File 'lib/test_gem/myfile.rb', line 4 def initialize file_location @file_location = file_location end |
Class Method Details
.first(file_location = @file_location) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/test_gem/myfile.rb', line 8 def self.first file_location=@file_location if File.exist?(file_location) File.open(file_location, "r"){|f| f.readlines[0].chomp} else raise RuntimeError, 'File Does not exist!' end end |
.last(file_location = @file_location) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/test_gem/myfile.rb', line 16 def self.last file_location=@file_location if File.exist?(file_location) File.open(file_location,"r"){|f| f.readlines.last.chomp} else raise RuntimeError, 'File Does not exist!' end end |