module Rozi
Constants
- DATUMS
A list of datums accepted by Ozi Explorer.
- ROOT
- VERSION
Public Class Methods
Writes an enumerable of waypoints to a file
@param [Enumerable] waypoints @param [String] file_path @param [Hash] properties Any extra keyword arguments are processed as
waypoint file properties
# File lib/rozi/waypoints.rb, line 14 def self.write_waypoints(waypoints, file_path, **properties) wpt_file = WaypointFile.open(file_path, "w") wpt_file.write_properties(WaypointFileProperties.new(**properties)) wpt_file.write waypoints wpt_file.close nil end
Public Instance Methods
Opens a file with the correct settings for usage with Ozi Explorer
The file instance has UTF-8 internal encoding and ISO-8859-1 external encoding. When writing, all line endings are converted to CRLF. When reading, all line endings are converted to LF.
@overload open_file
(path, mode=“r”)
@param [String] path @return [File]
@overload open_file
(path, mode=“r”)
Can be called with a block, just like file +File.open+. @yieldparam [File] file @return [void]
# File lib/rozi/module_functions.rb, line 24 def open_file(path, mode="r") file = File.open(path, mode) opts = {undef: :replace, replace: "?"} if mode.include? "w" opts[:crlf_newline] = true else opts[:universal_newline] = true end file.set_encoding("ISO-8859-1", "UTF-8", opts) if block_given? yield file file.close return nil else return file end end
Loads all ruby files under lib/rozi. Called automatically when requiring “rozi.rb”.
# File lib/rozi.rb, line 13 def require_lib this_dir = File.absolute_path(File.dirname(__FILE__)) source_files = Dir[File.join(this_dir, "rozi/**/*.rb")] source_files.each { |file| require_relative file } end
Writes an enumerable of names to a file
All keyword arguments are used as track properties.
@param [Enumerable] enumerable @param [String] file_path
# File lib/rozi/name_search.rb, line 14 def write_nst(enumerable, file_path, **properties) NameSearchTextFile.open(file_path, "w") { |nst| nst.write_properties NameSearchProperties.new(**properties) enumerable.each { |name| nst.write_name name } } return nil end
Writes an enumerable of track points to a file
All keyword arguments are used as track properties.
@param [Enumerable] enumerable @param [String] file_path
# File lib/rozi/tracks.rb, line 14 def write_track(enumerable, file_path, **properties) TrackFile.open(file_path, "w") { |track_file| track_file.write_track_properties TrackProperties.new(**properties) track_file.write enumerable } end