Class: Get::Smart::Memory

Inherits:
Object
  • Object
show all
Defined in:
lib/get/smart/memory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMemory

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_filesObject (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

#closeObject



12
13
14
# File 'lib/get/smart/memory.rb', line 12

def close
  memory_file.close
end

#last_shown_datetimeObject



23
24
25
26
27
# File 'lib/get/smart/memory.rb', line 23

def last_shown_datetime
  return unless exists?

  memory_file.mtime
end

#resetObject



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