Class: NameFileSource

Inherits:
NameSource show all
Defined in:
lib/namesource.rb

Instance Method Summary collapse

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

#closeObject



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