Sha256: fc82f36fce8be600453fcbec8619bcece3412423514a41b94790370f4b4b5cd7
Contents?: true
Size: 559 Bytes
Versions: 4
Compression:
Stored size: 559 Bytes
Contents
# frozen_string_literal: true require "yaml" require "fileutils" module Vlcraptor class Settings attr_reader :path, :preferences def initialize(path) @path = path.gsub("~", File.expand_path("~")) FileUtils.mkdir_p File.dirname(@path) @preferences = File.exist?(@path) ? YAML.load_file(@path) : {} end def [](key) preferences[key] end def []=(key, value) preferences[key] = value persist end def persist File.open(path, "w") { |f| f.puts preferences.to_yaml } end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
vlcraptor-0.5.0 | lib/vlcraptor/settings.rb |
vlcraptor-0.4.0 | lib/vlcraptor/settings.rb |
vlcraptor-0.3.0 | lib/vlcraptor/settings.rb |
vlcraptor-0.2.0 | lib/vlcraptor/settings.rb |