Module: PathManager
- Defined in:
- lib/path_manager.rb
Class Method Summary collapse
- .containsPath ⇒ Object
- .deletePathFile ⇒ Object
- .inputPath(path) ⇒ Object
- .outputPath ⇒ Object
- .pathFileName ⇒ Object
- .storagePathFile(path) ⇒ Object
Class Method Details
.containsPath ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/path_manager.rb', line 39 def self.containsPath if File.exists?(self.pathFileName) puts '当前根目录: ' IO.foreach(self.pathFileName) { |c| puts c } return true else puts "根目录不存在,请添加!" return false end end |
.deletePathFile ⇒ Object
35 36 37 |
# File 'lib/path_manager.rb', line 35 def self.deletePathFile File.delete(self.pathFileName) end |
.inputPath(path) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/path_manager.rb', line 6 def self.inputPath(path) if self.containsPath puts "确定您的新路径?为" + path puts "y/n" val = STDIN.gets if val =~ /Y|y/ self.deletePathFile self.storagePathFile(path) return else p "结束" return end end self.storagePathFile(path) end |
.outputPath ⇒ Object
24 25 26 |
# File 'lib/path_manager.rb', line 24 def self.outputPath return IO.readlines(self.pathFileName)[0] end |
.pathFileName ⇒ Object
52 53 54 |
# File 'lib/path_manager.rb', line 52 def self.pathFileName return "dfb_path_file" end |
.storagePathFile(path) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/path_manager.rb', line 28 def self.storagePathFile(path) file = File.new(self.pathFileName,"w"); file << path file.close; puts "更改路径成功!路径为:" + path end |