Module: BayesMotel::Persistence

Defined in:
lib/bayes_motel/persistence.rb

Class Method Summary collapse

Class Method Details

.read(name) ⇒ Object



10
11
12
# File 'lib/bayes_motel/persistence.rb', line 10

def self.read(name)
  Marshal.load(File.read("#{name}"))
end

.write(corpus) ⇒ Object

TODO Make this a little more Ruby idiomatic and pluggable for filesystems, databases, etc.



5
6
7
8
9
# File 'lib/bayes_motel/persistence.rb', line 5

def self.write(corpus)
  File.open("#{corpus.name}", 'w') do |file|
    Marshal.dump(corpus, file)
  end
end