logger()
click to toggle source
def logger
@logger ||= Logger.new(logger_output || STDERR, level: logger_level || "warn", progname: "rbs")
end
logger_level=(level)
click to toggle source
def logger_level=(level)
@logger_level = level
@logger = nil
end
logger_output=(val)
click to toggle source
def logger_output=(val)
@logger_output = val
@logger = nil
end
print_warning()
click to toggle source
def print_warning()
@warnings ||= Set[]
message = yield()
unless @warnings.include?(message)
@warnings << message
logger.warn { message }
end
end
to_string(location, default: "*:*:*...*:*")
click to toggle source
def self.to_string(location, default: "*:*:*...*:*")
location&.to_s || default
end
add_optional_child(name, range)
click to toggle source
def add_optional_child(name, range)
if range
_add_optional_child(name, range.begin, range.end)
else
_add_optional_no_child(name);
end
end
add_required_child(name, range)
click to toggle source
def add_required_child(name, range)
_add_required_child(name, range.begin, range.end)
end
each_optional_key(&block)
click to toggle source
def each_optional_key(&block)
if block
_optional_keys.uniq.each(&block)
else
enum_for(:each_optional_key)
end
end
each_required_key(&block)
click to toggle source
def each_required_key(&block)
if block
_required_keys.uniq.each(&block)
else
enum_for(:each_required_key)
end
end
key?(name)
click to toggle source
def key?(name)
optional_key?(name) || required_key?(name)
end
optional_key?(name)
click to toggle source
def optional_key?(name)
_optional_keys.include?(name)
end
required_key?(name)
click to toggle source
def required_key?(name)
_required_keys.include?(name)
end