38 lines
1.0 KiB
Ruby
38 lines
1.0 KiB
Ruby
# Module for the main vrobot4 program and global info.
|
|
module Vrobot4
|
|
# The current program version.
|
|
Version = "4.00".freeze
|
|
|
|
def self.debug=(set) @@debug = set end # Sets the current debug level.
|
|
def self.debug ( ) @@debug end # Gets the current debug level.
|
|
|
|
# Logs to the console.
|
|
#
|
|
# @param lv [Symbol]
|
|
# - If +:DEBUG+, this message will not be printed if the global debug
|
|
# level is less than 1.
|
|
# - If +:DEBUGV+, this message will not be printed if the global debug
|
|
# level is less than 2.
|
|
# @return [Boolean] true if the message was printed, false otherwise
|
|
def self.log lv, *text
|
|
if (lv != :DEBUG || @@debug >= 1) &&
|
|
(lv != :DEBUGV || @@debug >= 2)
|
|
puts "[" + lv.to_s.ljust(6) + "] " + text.join(" ")
|
|
true
|
|
else
|
|
false
|
|
end
|
|
end
|
|
|
|
# Checks if the argument +s+ is a numeric string.
|
|
# @param str [String] the string to check
|
|
def self.is_num? str
|
|
/\A[-+]?[0-9]*\.?[0-9]+\Z/ === str
|
|
end
|
|
|
|
private
|
|
@@debug = 0
|
|
end
|
|
|
|
## EOF
|