Class: YrWeather::FileCache

Inherits:
Object
  • Object
show all
Defined in:
lib/yr_weather.rb

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ FileCache

Returns a new instance of FileCache.



57
58
59
60
# File 'lib/yr_weather.rb', line 57

def initialize(params)
  @latitude  = params[:latitude]
  @longitude = params[:longitude]
end

Instance Method Details

#from_cacheObject



67
68
69
70
71
72
# 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) ⇒ Object



62
63
64
65
# File 'lib/yr_weather.rb', line 62

def to_cache(data)
  file_name = cache_file_name
  File.write(file_name, data.to_json)
end