Module: SkippyLib::Resource

Defined in:
modules/resource.rb

Overview

Since:

  • 3.0.0

Constant Summary collapse

VECTOR_FILETYPE =

The supported file format for vector icons depend on the platform.

Since:

  • 3.0.0

(Platform.mac? ? 'pdf' : 'svg').freeze

Class Method Summary collapse

Class Method Details

.icon_path(path) ⇒ String

Provide the path to a bitmap icon, which will be used for older SketchUp versions that doesn't support vector formats.

For versions that do support vector formats it will return the path with the file extension that is compatible with the running OS.

If the vector variant doesn't exist the original path will be returned.

Parameters:

  • path (String)

Returns:

  • (String)

Since:

  • 3.0.0



24
25
26
27
28
29
# File 'modules/resource.rb', line 24

def self.icon_path(path)
  return path unless Sketchup.version.to_i > 15

  vector_icon = self.vector_path(path)
  File.exist?(vector_icon) ? vector_icon : path
end

.vector_path(path) ⇒ String

Parameters:

  • path (String)

Returns:

  • (String)

Since:

  • 3.0.0



34
35
36
37
38
# File 'modules/resource.rb', line 34

def self.vector_path(path)
  dir = File.dirname(path)
  basename = File.basename(path, '.*')
  File.join(dir, "#{basename}.#{VECTOR_FILETYPE}")
end