class Cache

Public Class Methods

new( name ) click to toggle source
# File lib/tulipmania/cache.rb, line 4
def initialize( name )
  @name = name
end

Public Instance Methods

read() click to toggle source
# File lib/tulipmania/cache.rb, line 14
def read
  if File.exists?( @name )
    data = File.open( @name, 'r:bom|utf-8' ).read
    JSON.parse( data )
  else
    nil
  end
end
write( data ) click to toggle source
# File lib/tulipmania/cache.rb, line 8
def write( data )
  File.open( @name, 'w:utf-8' ) do |f|
    f.write JSON.pretty_generate( data )
  end
end