class Tamiyo::DataStore

Public Class Methods

new() click to toggle source
# File lib/tamiyo/data_store.rb, line 8
def initialize
  @data_dir = ensure_tamiyo_data_dir
  @custom_sets_path = path_for 'custom_sets.yaml'
end

Public Instance Methods

ensure_tamiyo_data_dir() click to toggle source
# File lib/tamiyo/data_store.rb, line 13
def ensure_tamiyo_data_dir
  data_dir = File.join Dir.home, '.tamiyo'
  FileUtils.mkpath data_dir
  data_dir
end
load_custom_sets() click to toggle source
# File lib/tamiyo/data_store.rb, line 23
def load_custom_sets
  File.exists?(@custom_sets_path) ? begin
    File.open(@custom_sets_path, 'r') do |f|
      yaml_from f.read
    end
  end : {}
end
path_for(file_name) click to toggle source
# File lib/tamiyo/data_store.rb, line 19
def path_for(file_name)
  File.join @data_dir, file_name
end
persist_custom_sets(data) click to toggle source
# File lib/tamiyo/data_store.rb, line 31
def persist_custom_sets(data)
  File.open(@custom_sets_path, 'w') do |f|
    f.write yaml_of data
  end
end