代码拉取完成,页面将自动刷新
# Copyright 2016 Trimble Inc
# Licensed under the MIT license
module Examples
# Finds and returns the filename for each of the root .rb files in the
# examples folder.
#
# @yield [String] filename
#
# @return [Array<String>] files
def self.rb_files(include_subfolders = false)
examples_path = File.join(__dir__, 'examples')
folders = include_subfolders ? '**' : '*'
examples_pattern = File.join(examples_path, folders, '*.rb')
Dir.glob(examples_pattern).each { |filename|
yield filename
}
end
# Utility method to mute Ruby warnings for whatever is executed by the block.
def self.mute_warnings(&block)
old_verbose = $VERBOSE
$VERBOSE = nil
result = block.call
ensure
$VERBOSE = old_verbose
result
end
# Utility method to quickly reload the tutorial files. Useful for development.
#
# @return [Integer] Number of files reloaded.
def self.reload
self.mute_warnings do
load __FILE__
files = self.rb_files(true) { |filename|
load filename
}
puts "Reloaded #{files.size} files" if $VERBOSE
files.size + 1
end
end
# This runs when this file is loaded and adds the location of each of the
# tutorials folders to the load path such that the tutorials can be loaded
# into SketchUp directly from the repository.
self.rb_files { |filename|
begin
path = File.dirname(filename)
$LOAD_PATH << path
require filename
rescue LoadError => error
warn "Failed to load: #{filename}"
warn error.inspect
warn error.description
end
}
end # module Examples
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。