class YrWeather::FileCache
Public Class Methods
new(params)
click to toggle source
# File lib/yr_weather.rb, line 57 def initialize(params) @latitude = params[:latitude] @longitude = params[:longitude] end
Public Instance Methods
from_cache()
click to toggle source
# File lib/yr_weather.rb, line 67 def from_cache file_name = cache_file_name if File.file?(cache_file_name) File.read(file_name) end end
to_cache(data)
click to toggle source
# File lib/yr_weather.rb, line 62 def to_cache(data) file_name = cache_file_name File.write(file_name, data.to_json) end
Private Instance Methods
cache_file_name()
click to toggle source
# File lib/yr_weather.rb, line 76 def cache_file_name file_name = "yr_weather.#{@latitude}.#{@longitude}.tmp" File.join(Dir.tmpdir,file_name) end