Class: Rozi::TrackFile
- Inherits:
-
FileWrapperBase
- Object
- FileWrapperBase
- Rozi::TrackFile
- Includes:
- Shared
- Defined in:
- lib/rozi/tracks.rb
Overview
A thin wrapper around a file object made for reading and writing tracks
Instance Attribute Summary
Attributes inherited from FileWrapperBase
Instance Method Summary collapse
-
#write(enumerable) ⇒ Object
Writes an enumerable of track points to the file.
-
#write_track_point(track_point) ⇒ nil
Writes a track point to the file.
-
#write_track_properties(properties) ⇒ nil
Writes track properties to the file.
Methods included from Shared
#datum_valid?, #escape_text, #interpret_color, #unescape_text
Methods inherited from FileWrapperBase
#close, #closed?, #initialize, open, #rewind
Constructor Details
This class inherits a constructor from Rozi::FileWrapperBase
Instance Method Details
#write(enumerable) ⇒ Object
Writes an enumerable of track points to the file
128 129 130 131 132 133 134 |
# File 'lib/rozi/tracks.rb', line 128 def write(enumerable) enumerable.each { |track_point| self.write_track_point(track_point) } nil end |
#write_track_point(track_point) ⇒ nil
Writes a track point to the file
114 115 116 117 118 119 120 121 |
# File 'lib/rozi/tracks.rb', line 114 def write_track_point(track_point) ensure_track_properties @file.write serialize_track_point(track_point) @file.write "\n" nil end |
#write_track_properties(properties) ⇒ nil
Writes track properties to the file
The file must be empty when this method is called!
98 99 100 101 102 103 104 105 106 |
# File 'lib/rozi/tracks.rb', line 98 def write_track_properties(properties) if @file.size > 0 raise "Can't write file properties, file is not empty" end @file.write serialize_track_properties(properties) nil end |