Module: Rozi::OziFunctions

Included in:
NameSearchText, Track, TrackWriter, Waypoint, WaypointWriter
Defined in:
lib/rozi/ozi_functions.rb

Overview

Contains general functions for working with Ozi Explorer file formats.

Instance Method Summary collapse

Instance Method Details

#datum_valid?(datum) ⇒ Boolean

Checks if datum is a valid datum according to Ozi Explorer.

Returns:

  • (Boolean)

    true if datum is valid



43
44
45
# File 'lib/rozi/ozi_functions.rb', line 43

def datum_valid?(datum)
  Rozi::DATUMS.include? datum
end

#escape_text(text) ⇒ String

Escapes commas so the text can be used in Ozi file formats.

Parameters:

  • text (String)

Returns:

  • (String)


14
15
16
# File 'lib/rozi/ozi_functions.rb', line 14

def escape_text(text)
  text.gsub(/,/, 209.chr.encode("UTF-8", "ISO-8859-1"))
end

#interpret_color(color) ⇒ Integer

Converts the input to an RGB color represented by an integer.

Examples:

interpret_color(255)      # => 255
interpret_color("ABCDEF") # => 15715755

Parameters:

  • color (String, Integer)

    Can be a RRGGBB hex string or an integer.

Returns:

  • (Integer)


28
29
30
31
32
33
34
35
36
# File 'lib/rozi/ozi_functions.rb', line 28

def interpret_color(color)
  if color.is_a? String
    # Turns RRGGBB into BBGGRR for hex conversion.
    color = color[-2..-1] << color[2..3] << color[0..1]
    color = color.to_i(16)
  end

  color
end