Class: Fitting::Storage::YamlFile
- Inherits:
-
Object
- Object
- Fitting::Storage::YamlFile
- Defined in:
- lib/fitting/storage/yaml_file.rb
Constant Summary collapse
- NAME =
'storage.yaml'.freeze
Class Method Summary collapse
- .craft ⇒ Object
- .destroy ⇒ Object
- .load ⇒ Object
- .push(key, value) ⇒ Object
- .save(json) ⇒ Object
- .tests ⇒ Object
Class Method Details
.craft ⇒ Object
8 9 10 |
# File 'lib/fitting/storage/yaml_file.rb', line 8 def self.craft save("---\n") end |
.destroy ⇒ Object
32 33 34 |
# File 'lib/fitting/storage/yaml_file.rb', line 32 def self.destroy File.delete(NAME) end |
.load ⇒ Object
28 29 30 |
# File 'lib/fitting/storage/yaml_file.rb', line 28 def self.load YAML.load(File.read(NAME)) end |
.push(key, value) ⇒ Object
18 19 20 21 |
# File 'lib/fitting/storage/yaml_file.rb', line 18 def self.push(key, value) save(tests + YAML.dump(key => value)[4..-1]) rescue end |
.save(json) ⇒ Object
12 13 14 15 16 |
# File 'lib/fitting/storage/yaml_file.rb', line 12 def self.save(json) File.open(NAME, 'w') do |file| file.write(json) end end |
.tests ⇒ Object
23 24 25 26 |
# File 'lib/fitting/storage/yaml_file.rb', line 23 def self.tests File.read(NAME) rescue end |