Class: TestGem::MyFile
- Inherits:
-
Object
- Object
- TestGem::MyFile
- Defined in:
- lib/test_gem/my_file.rb
Instance Attribute Summary collapse
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(file_path) ⇒ MyFile
constructor
A new instance of MyFile.
Constructor Details
#initialize(file_path) ⇒ MyFile
Returns a new instance of MyFile.
28 29 30 |
# File 'lib/test_gem/my_file.rb', line 28 def initialize(file_path) @file_path = File.(file_path) end |
Instance Attribute Details
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
26 27 28 |
# File 'lib/test_gem/my_file.rb', line 26 def file_path @file_path end |
Class Method Details
.first(path) ⇒ Object
32 33 34 |
# File 'lib/test_gem/my_file.rb', line 32 def MyFile.first(path) File.open(path) {|file| file.readline} end |
.last(path) ⇒ Object
36 37 38 |
# File 'lib/test_gem/my_file.rb', line 36 def MyFile.last(path) File.open(path) {|file| file.readlines[-1]} end |