class Object
Constants
- Dirs2D
- Point2D
- Point3D
- Point4D
- Seg2D
Public Instance Methods
crequire(requireName, gem_name = nil)
click to toggle source
Require the given ruby file and if loading fails, try to install the gem of the same name or given parameter
# File lib/cem/ccommon.rb, line 5 def crequire(requireName, gem_name = nil) require requireName rescue LoadError gem_name = requireName if gem_name.nil? system("gem install #{gem_name}") Gem.clear_paths require requireName end
isHTML5Element(element)
click to toggle source
# File lib/cem/ccommon.rb, line 117 def isHTML5Element(element) # https://html.spec.whatwg.org/#elements-3 @valid_elements ||= %w(a abbr address area article aside audio b base bdi bdo blockquote body br button canvas caption cite code col colgroup data datalist dd del details dfn dialog div dl dt em embed fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 head header hgroup hr html i iframe img input ins kbd label legend li link main map mark math menu meta meter nav noscript object ol optgroup option output p param picture pre progress q rp rt ruby s samp script section select slot small source span strong style sub summary sup svg table tbody td template textarea tfoot th thead time title tr track u ul var video wbr) return @valid_elements.include?(element.to_s.downcase) end
peql(actual, expected=:unknown_peql_token, msg=nil)
click to toggle source
Puts+eql? == peql Performs a equal comparison and outputs the result to console in the form
“#{msg}: Expected #{expected}, but got #{actual}”
expected may be kept empty, in which case the msg is adjusted
# File lib/cem/ccommon.rb, line 22 def peql(actual, expected=:unknown_peql_token, msg=nil) if expected == :unknown_peql_token puts "#{msg}: Didn't know what to expect and got '#{actual}'" else if actual == expected puts "#{msg}: Expected '#{expected}' and got it!" else puts "#{msg}: Expected '#{expected}', but got '#{actual}!" end end end
wsl?()
click to toggle source
Returns true if this script is running on the Windows Sub-System for Linux, i.e. under Linux where the host is Windows.
If true, interoperability with Windows is possible.
# File lib/cem/ccommon.rb, line 96 def wsl? @@wsl ||= File.file?('/proc/version') && File.open('/proc/version', &:gets).downcase.include?("microsoft") end
wslpath(path, mode = "")
click to toggle source
If on wsl? then the given is converted from a Windows path to a Linux path (e.g. “C:" becomes ”/mnt/c/“)
Uses the wslpath command, passes mode to wslpath:
-a force result to absolute path format -u translate from a Windows path to a WSL path (default) -w translate from a WSL path to a Windows path -m translate from a WSL path to a Windows path, with '/' instead of '\'
# File lib/cem/ccommon.rb, line 111 def wslpath(path, mode = "") return path if !wsl? return `wslpath #{mode} '#{path}'`.strip end