Class: PositronicBrain::Persistence::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/positronic_brain/persistence/persistence.rb

Direct Known Subclasses

Classifier::Base

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dump_path, options = {}) ⇒ Base

Returns a new instance of Base.



8
9
10
11
# File 'lib/positronic_brain/persistence/persistence.rb', line 8

def initialize(dump_path, options = {})
  @dump_path, @options = dump_path, options
  load || init
end

Instance Attribute Details

#dump_pathObject (readonly)

Returns the value of attribute dump_path.



6
7
8
# File 'lib/positronic_brain/persistence/persistence.rb', line 6

def dump_path
  @dump_path
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/positronic_brain/persistence/persistence.rb', line 6

def options
  @options
end

#persistenceObject (readonly)

Returns the value of attribute persistence.



6
7
8
# File 'lib/positronic_brain/persistence/persistence.rb', line 6

def persistence
  @persistence
end

Instance Method Details

#==(other) ⇒ Object



18
19
20
# File 'lib/positronic_brain/persistence/persistence.rb', line 18

def ==(other)
  @persistence == other.persistence
end

#dumpObject



13
14
15
16
# File 'lib/positronic_brain/persistence/persistence.rb', line 13

def dump
  ensure_dump_directory
  File.open(@dump_path, 'w'){ |f| f.puts Marshal.dump @persistence }
end