Sha256: 9ebdd8f6d458d8bfe28f5719cbaa19560130ea4880b5b60e653c929a2e60e499

Contents?: true

Size: 468 Bytes

Versions: 1

Compression:

Stored size: 468 Bytes

Contents

module Nin
  class TomlStore
    DEFAULT_FILE = "#{ENV['HOME']}/.todos.toml"

    attr_reader :file

    def initialize(file = DEFAULT_FILE)
      @file = file

      init_store
    end

    def read
      TomlRB.load_file(@file)
    end

    def write(hash)
      File.open(@file, 'w') do |file|
        file.write(TomlRB.dump(hash))
      end
    end

    private

    def init_store
      return if File.exist?(@file)

      File.open(@file, "w")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nin-0.7.0 lib/nin/toml_store.rb