Class: Shoestring::Cache

Inherits:
Base
  • Object
show all
Defined in:
lib/shoestring/cache.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

check

Constructor Details

#initialize(key, &block) ⇒ Cache

Returns a new instance of Cache.



5
6
7
8
# File 'lib/shoestring/cache.rb', line 5

def initialize(key, &block)
  @key = key
  @block = block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



3
4
5
# File 'lib/shoestring/cache.rb', line 3

def block
  @block
end

#keyObject (readonly)

Returns the value of attribute key.



3
4
5
# File 'lib/shoestring/cache.rb', line 3

def key
  @key
end

Instance Method Details

#checkObject



10
11
12
13
# File 'lib/shoestring/cache.rb', line 10

def check
  version = block.call(old_version)
  File.open(cache_file, 'w') { |f| f.puts(version || 'cached') }
end