module Rozi::Shared
Contains general functions for working with Ozi Explorer file formats
Public Instance Methods
datum_valid?(datum)
click to toggle source
Checks if datum
is a valid datum according to Ozi Explorer
@return [Boolean] true if datum
is valid
# File lib/rozi/shared.rb, line 49 def datum_valid?(datum) Rozi::DATUMS.include? datum end
escape_text(text)
click to toggle source
Escapes commas so the text can be used in Ozi file formats
@param [String] text @return [String]
# File lib/rozi/shared.rb, line 13 def escape_text(text) text.gsub(/,/, "Ñ") end
interpret_color(color)
click to toggle source
Converts the input to an RGB color represented by an integer
@param [String, Integer] color Can be a RRGGBB hex string or an integer @return [Integer]
@example
interpret_color(255) # => 255 interpret_color("ABCDEF") # => 15715755
# 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)
click to toggle source
Undoes the effect of {Rozi::Shared#escape_text}
# File lib/rozi/shared.rb, line 20 def unescape_text(text) text.gsub(/Ñ/, ",") end