Class: Get::Smart::Memory
- Inherits:
-
Object
- Object
- Get::Smart::Memory
- Defined in:
- lib/get/smart/memory.rb
Instance Attribute Summary collapse
-
#shown_files ⇒ Object
readonly
Returns the value of attribute shown_files.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize ⇒ Memory
constructor
A new instance of Memory.
- #last_shown_datetime ⇒ Object
- #reset ⇒ Object
- #write(file_path) ⇒ Object
Constructor Details
#initialize ⇒ Memory
Returns a new instance of Memory.
4 5 6 |
# File 'lib/get/smart/memory.rb', line 4 def initialize @shown_files = memory_file.readlines.compact_blank.map(&:strip) end |
Instance Attribute Details
#shown_files ⇒ Object (readonly)
Returns the value of attribute shown_files.
2 3 4 |
# File 'lib/get/smart/memory.rb', line 2 def shown_files @shown_files end |
Instance Method Details
#close ⇒ Object
12 13 14 |
# File 'lib/get/smart/memory.rb', line 12 def close memory_file.close end |
#last_shown_datetime ⇒ Object
23 24 25 26 27 |
# File 'lib/get/smart/memory.rb', line 23 def last_shown_datetime return unless exists? memory_file.mtime end |
#reset ⇒ Object
16 17 18 19 20 21 |
# File 'lib/get/smart/memory.rb', line 16 def reset Get::Smart.log("Resetting memory") memory_file.truncate(0) memory_file.rewind @shown_files = [] end |
#write(file_path) ⇒ Object
8 9 10 |
# File 'lib/get/smart/memory.rb', line 8 def write(file_path) memory_file.write("#{file_path}\n") end |