Class: Autosftp::FileAccess

Inherits:
Object
  • Object
show all
Defined in:
lib/autosftp/file_access.rb

Constant Summary collapse

INIT_FILE =
'.autosftp'

Class Method Summary collapse

Class Method Details

.createObject



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

Returns:

  • (Boolean)


17
18
19
# File 'lib/autosftp/file_access.rb', line 17

def exist?
  File.exist? path
end

.pathObject



13
14
15
# File 'lib/autosftp/file_access.rb', line 13

def path
  File.join(Dir.pwd, INIT_FILE)
end

.readObject



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