Class: NameFileSource
- Inherits:
-
NameSource
- Object
- NameSource
- NameFileSource
- Defined in:
- lib/namesource.rb
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(file_name) ⇒ NameFileSource
constructor
A new instance of NameFileSource.
- #name(file, md, path) ⇒ Object
Constructor Details
#initialize(file_name) ⇒ NameFileSource
Returns a new instance of NameFileSource.
23 24 25 |
# File 'lib/namesource.rb', line 23 def initialize(file_name) @file_name = file_name end |
Instance Method Details
#close ⇒ Object
41 42 43 |
# File 'lib/namesource.rb', line 41 def close @file.close if @file end |
#name(file, md, path) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/namesource.rb', line 27 def name(file, md, path) unless @file and @path == path @file.close if @file @path = path fn = File.join(path, @file_name) if File.exists? fn @file = File.open(fn) else @file = File.open(@file_name) end end @file.readline.chomp end |