Class: ArchivePrivate
Constant Summary collapse
- FILE_NAME =
'private'
Constants inherited from Archive
Archive::EXTENSION_FILE, Archive::FILE_PATH_KEYS, Archive::MODE_WRITE, Archive::ROOT_PATH_FILE
Instance Attribute Summary
Attributes inherited from Archive
Instance Method Summary collapse
-
#initialize ⇒ ArchivePrivate
constructor
A new instance of ArchivePrivate.
- #read ⇒ Object
- #write(text) ⇒ Object
Methods inherited from Archive
#decode, #encode, #full_name, #set_name
Constructor Details
#initialize ⇒ ArchivePrivate
Returns a new instance of ArchivePrivate.
5 6 7 |
# File 'lib/archive_private.rb', line 5 def initialize set_name(FILE_NAME) end |
Instance Method Details
#read ⇒ Object
9 10 11 12 |
# File 'lib/archive_private.rb', line 9 def read file = File.open full_name JSON.parse(decode(file.read), symbolize_names: true) end |
#write(text) ⇒ Object
14 15 16 17 18 |
# File 'lib/archive_private.rb', line 14 def write(text) file = File.open(full_name, Archive::MODE_WRITE) file.puts encode JSON.generate text file.close end |