Class: QiitaMail::Storage
- Inherits:
-
Object
- Object
- QiitaMail::Storage
- Defined in:
- lib/qiita_mail/storage.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_reading(uuid) ⇒ Object
-
#initialize(filename = Storage.default_filename) ⇒ Storage
constructor
A new instance of Storage.
- #reading?(uuid) ⇒ Boolean
- #save ⇒ Object
Constructor Details
#initialize(filename = Storage.default_filename) ⇒ Storage
Returns a new instance of Storage.
16 17 18 19 20 21 22 23 24 |
# File 'lib/qiita_mail/storage.rb', line 16 def initialize(filename = Storage.default_filename) @filename = filename if File.exist?(@filename) @data = MarshalFile.load(@filename) else @data = {} end end |
Class Method Details
.default_filename ⇒ Object
12 13 14 |
# File 'lib/qiita_mail/storage.rb', line 12 def self.default_filename File.('~/.qiita_mail.marshal') end |
Instance Method Details
#add_reading(uuid) ⇒ Object
26 27 28 29 |
# File 'lib/qiita_mail/storage.rb', line 26 def add_reading(uuid) @data[:reading] ||= {} @data[:reading][uuid] = true end |
#reading?(uuid) ⇒ Boolean
31 32 33 34 35 36 37 |
# File 'lib/qiita_mail/storage.rb', line 31 def reading?(uuid) if @data.has_key? :reading @data[:reading].has_key? uuid else false end end |
#save ⇒ Object
39 40 41 |
# File 'lib/qiita_mail/storage.rb', line 39 def save MarshalFile.save(@filename, @data) end |