Class: Autosftp::FileAccess
- Inherits:
-
Object
- Object
- Autosftp::FileAccess
- Defined in:
- lib/autosftp/file_access.rb
Constant Summary collapse
- INIT_FILE =
'.autosftp'
Class Method Summary collapse
- .create ⇒ Object
- .delete(word) ⇒ Object
- .exist? ⇒ Boolean
- .path ⇒ Object
- .read ⇒ Object
- .save(word, hash) ⇒ Object
Class Method Details
.create ⇒ Object
9 10 11 |
# File 'lib/autosftp/file_access.rb', line 9 def create File.open(path, "w").close() end |
.delete(word) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/autosftp/file_access.rb', line 37 def delete word read_file = YAML.load_file path read_file.delete(word) f = open(path, "w") f.write(YAML.dump(read_file)) f.close end |
.exist? ⇒ Boolean
17 18 19 |
# File 'lib/autosftp/file_access.rb', line 17 def exist? File.exist? path end |
.path ⇒ Object
13 14 15 |
# File 'lib/autosftp/file_access.rb', line 13 def path File.join(Dir.pwd, INIT_FILE) end |
.read ⇒ Object
33 34 35 |
# File 'lib/autosftp/file_access.rb', line 33 def read YAML.load_file path end |
.save(word, hash) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/autosftp/file_access.rb', line 21 def save word, hash save_file = YAML.load_file path if false == save_file save_file = {} end save_file[word] = hash f = open(path, "w") f.write(YAML.dump(save_file)) f.close end |