Class: SpriteKit::FileCache

Inherits:
Object
  • Object
show all
Defined in:
mygame/lib/sprite_kit/file_cache.rb

Instance Method Summary collapse

Constructor Details

#initializeFileCache

Returns a new instance of FileCache.



3
4
5
# File 'mygame/lib/sprite_kit/file_cache.rb', line 3

def initialize
  @cache = {}
end

Instance Method Details

#add(path) ⇒ Object



7
8
9
10
11
12
13
# File 'mygame/lib/sprite_kit/file_cache.rb', line 7

def add(path)
  stats = GTK.stat_file
  if stats && @cache[path].to_i < stats.mod_time
    GTK.reset_sprite(path)
    @cache[path] = stats.mod_time
  end
end

#delete(path) ⇒ Object



15
16
17
# File 'mygame/lib/sprite_kit/file_cache.rb', line 15

def delete(path)
  @cache.delete(path)
end

#get(path) ⇒ Object



23
24
25
# File 'mygame/lib/sprite_kit/file_cache.rb', line 23

def get(path)
  @cache.fetch(path)
end

#has?(path) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'mygame/lib/sprite_kit/file_cache.rb', line 19

def has?(path)
  @cache[path] != nil
end