Class: TestGem::MyFile

Inherits:
Object
  • Object
show all
Defined in:
lib/test_gem/my_file.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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.expand_path(file_path)
end

Instance Attribute Details

#file_pathObject (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