Class: FileManager

Inherits:
Object
  • Object
show all
Defined in:
lib/team-secrets/file_manager.rb

Direct Known Subclasses

ManifestManager, SecretManager, UserManager

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataObject

Returns the value of attribute data.



5
6
7
# File 'lib/team-secrets/file_manager.rb', line 5

def data
  @data
end

Instance Method Details

#loadFile(file = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/team-secrets/file_manager.rb', line 7

def loadFile(file = nil)
    if block_given?
        string_data = yield
    else
        raise 'No file given' if file.nil?
        string_data = File.read(file)
    end

    @data = YAML.load(string_data)
end

#writeFile(file = nil) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/team-secrets/file_manager.rb', line 18

def writeFile(file = nil)
    yaml = @data.to_yaml

    if block_given?
        yield yaml
    else
        raise 'No file given' if file.nil?
        File.write(file, yaml)
    end

    yaml
end