Module: Rozi::Shared

Included in:
NameSearchProperties, DatumSetter, TrackFile, TrackProperties, Waypoint, WaypointFile
Defined in:
lib/rozi/shared.rb

Overview

Contains general functions for working with Ozi Explorer file formats

Defined Under Namespace

Modules: DatumSetter

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



49
50
51
# File 'lib/rozi/shared.rb', line 49

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)


13
14
15
# File 'lib/rozi/shared.rb', line 13

def escape_text(text)
  text.gsub(/,/, "Ñ")
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)


34
35
36
37
38
39
40
41
42
# File 'lib/rozi/shared.rb', line 34

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

#unescape_text(text) ⇒ Object

Undoes the effect of #escape_text



20
21
22
# File 'lib/rozi/shared.rb', line 20

def unescape_text(text)
  text.gsub(/Ñ/, ",")
end