Class: Keep
- Inherits:
-
Object
- Object
- Keep
- Defined in:
- lib/keep/disk.rb,
lib/keep.rb,
lib/keep/yaml.rb
Overview
Keep::Disk is our hook into your system. We’ll save and open files here.
Pretty cool, amirite?
Defined Under Namespace
Constant Summary collapse
- VERSION =
'0.0.3'
Instance Attribute Summary collapse
-
#disk ⇒ Object
The in-memory Disk object.
-
#format ⇒ Object
The configuration format outputted.
-
#path ⇒ Object
The path to the configuration file.
Instance Method Summary collapse
-
#as(format) ⇒ Object
The format of configuration output.
-
#get(key) ⇒ Object
Returns the value of the specified key.
-
#initialize(path) ⇒ Keep
constructor
Initialize a new Keep instance.
-
#keys ⇒ Object
Accesses all of the keys we’re keeping.
-
#present?(key) ⇒ Boolean
Searches for the key in the in-memory Hash.
-
#set(key, value) ⇒ Object
Sets a value to a given key.
Constructor Details
Instance Attribute Details
#disk ⇒ Object
The in-memory Disk object.
16 17 18 |
# File 'lib/keep.rb', line 16 def disk @disk end |
#format ⇒ Object
The configuration format outputted.
19 20 21 |
# File 'lib/keep.rb', line 19 def format @format end |
#path ⇒ Object
The path to the configuration file.
13 14 15 |
# File 'lib/keep.rb', line 13 def path @path end |
Instance Method Details
#as(format) ⇒ Object
The format of configuration output.
format - the lowercase String representation of a class inheriting Disk
Returns nothing, defaults to ‘yaml’ right now.
50 51 52 |
# File 'lib/keep.rb', line 50 def as(format) @format = 'yaml' end |
#get(key) ⇒ Object
Returns the value of the specified key.
key - a String value for the key of this Hash
Returns the value if found, otherwise nil.
69 70 71 |
# File 'lib/keep.rb', line 69 def get(key) @disk.get(key) end |
#keys ⇒ Object
Accesses all of the keys we’re keeping.
Returns an Array of Objects.
83 84 85 |
# File 'lib/keep.rb', line 83 def keys @disk.keys end |
#present?(key) ⇒ Boolean
Searches for the key in the in-memory Hash.
Returns whether or not the key is present.
76 77 78 |
# File 'lib/keep.rb', line 76 def present?(key) @disk.present?(key) end |
#set(key, value) ⇒ Object
Sets a value to a given key.
key - a String value for the key of this Hash
value - an Object that maps to the key, will be serialized
Returns whether the save was successful.
60 61 62 |
# File 'lib/keep.rb', line 60 def set(key,value) @disk.set(key,value) end |