File: environment.rb

package info (click to toggle)
ruby-xdg 9.5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 136 kB
  • sloc: ruby: 199; makefile: 3
file content (36 lines) | stat: -rw-r--r-- 880 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# frozen_string_literal: true

module XDG
  # A convenience wrapper to all XDG functionality.
  class Environment
    def initialize home: Paths::Home, directories: Paths::Directory, environment: ENV
      @cache = Cache.new(home:, directories:, environment:)
      @config = Config.new(home:, directories:, environment:)
      @data = Data.new(home:, directories:, environment:)
      @state = State.new(home:, directories:, environment:)
      freeze
    end

    def cache_home = cache.home

    def config_home = config.home

    def config_dirs = config.directories

    def data_home = data.home

    def data_dirs = data.directories

    def state_home = state.home

    def to_s = "#{cache} #{config} #{data} #{state}"

    alias to_str to_s

    def inspect = "#<#{self.class}:#{object_id} #{self}>"

    private

    attr_reader :cache, :config, :data, :state
  end
end