Sha256: 1ea33801f7cb2582dfdeccccab36507f7496fbb1d75eba5a023b3dcb6c56a4d2
Contents?: true
Size: 488 Bytes
Versions: 8
Compression:
Stored size: 488 Bytes
Contents
require 'json' require 'pathname' module WorkGuide class Storage def initialize(name) @path = work_guide_dir.join(name.to_s) end def load if @path.exist? JSON.parse(@path.read) else [] end end def store(json) @path.open('w') do |f| f.puts json end end private def work_guide_dir Pathname.new(Dir.home).join('.work_guide').tap do |dir| dir.mkpath end end end end
Version data entries
8 entries across 8 versions & 1 rubygems