Save only necessary data into model
This commit is contained in:
parent
81b4f78187
commit
4052d534b2
1 changed files with 17 additions and 8 deletions
|
@ -15,7 +15,23 @@ module Ebooks
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.load(path)
|
def self.load(path)
|
||||||
Marshal.load(File.open(path, 'rb') { |f| f.read })
|
props = Marshal.load(File.open(path, 'rb') { |f| f.read })
|
||||||
|
@tokens = props[:tokens]
|
||||||
|
@sentences = props[:sentences]
|
||||||
|
@mentions = props[:mentions]
|
||||||
|
@keywords = props[:keywords]
|
||||||
|
end
|
||||||
|
|
||||||
|
def save(path)
|
||||||
|
File.open(path, 'wb') do |f|
|
||||||
|
f.write(Marshal.dump({
|
||||||
|
tokens: @tokens,
|
||||||
|
sentences: @sentences,
|
||||||
|
mentions: @mentions,
|
||||||
|
keywords: @keywords
|
||||||
|
}))
|
||||||
|
end
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
|
@ -98,13 +114,6 @@ module Ebooks
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def save(path)
|
|
||||||
File.open(path, 'wb') do |f|
|
|
||||||
f.write(Marshal.dump(self))
|
|
||||||
end
|
|
||||||
self
|
|
||||||
end
|
|
||||||
|
|
||||||
def fix(tweet)
|
def fix(tweet)
|
||||||
# This seems to require an external api call
|
# This seems to require an external api call
|
||||||
#begin
|
#begin
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue