Module: WebFont::LocalCache

Defined in:
lib/web_font/local_cache.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.cacheObject

Returns the value of attribute cache.



4
5
6
# File 'lib/web_font/local_cache.rb', line 4

def cache
  @cache
end

.cache_pathObject

Returns the value of attribute cache_path.



4
5
6
# File 'lib/web_font/local_cache.rb', line 4

def cache_path
  @cache_path
end

Class Method Details

.enable?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/web_font/local_cache.rb', line 21

def enable?
  cache && !!cache_path && Dir.exist?(cache_path)
end

.path(filename) ⇒ Object



6
7
8
9
# File 'lib/web_font/local_cache.rb', line 6

def path(filename)
  path = File.join(cache_path, filename)
  File.exist?(path) ? path : nil
end

.save(font) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/web_font/local_cache.rb', line 11

def save(font)
  return nil unless cache_path

  filename = File.basename(font)
  path     = File.join(cache_path, filename)
  FileUtils.copy(font, path) unless font == path

  path
end