Class: Bandicoot::SaveFile
- Inherits:
-
Object
- Object
- Bandicoot::SaveFile
- Defined in:
- lib/bandicoot/save_file.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#save_points ⇒ Object
readonly
Returns the value of attribute save_points.
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(file, save_points = nil) ⇒ SaveFile
constructor
A new instance of SaveFile.
- #write(key, retval) ⇒ Object
Constructor Details
#initialize(file, save_points = nil) ⇒ SaveFile
Returns a new instance of SaveFile.
18 19 20 21 |
# File 'lib/bandicoot/save_file.rb', line 18 def initialize(file, save_points=nil) @file = file @save_points = save_points end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
5 6 7 |
# File 'lib/bandicoot/save_file.rb', line 5 def file @file end |
#save_points ⇒ Object (readonly)
Returns the value of attribute save_points.
5 6 7 |
# File 'lib/bandicoot/save_file.rb', line 5 def save_points @save_points end |
Class Method Details
.continue(filename) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/bandicoot/save_file.rb', line 11 def self.continue(filename) file = File.open(filename, "r+") save_points = read_save_points(file) file.seek(0, IO::SEEK_END) new(file, save_points) end |
.create(filename) ⇒ Object
7 8 9 |
# File 'lib/bandicoot/save_file.rb', line 7 def self.create(filename) new(File.open(filename, "w")) end |
Instance Method Details
#close ⇒ Object
28 29 30 |
# File 'lib/bandicoot/save_file.rb', line 28 def close file.close end |
#write(key, retval) ⇒ Object
23 24 25 26 |
# File 'lib/bandicoot/save_file.rb', line 23 def write(key, retval) file.write([key, retval].to_msgpack) #file.fsync end |