Class: XDG::Paths::Directory

Inherits:
Any
  • Object
show all
Defined in:
lib/xdg/paths/directory.rb

Overview

A collection of XDG directories.

Constant Summary collapse

DELIMITER =
":"

Instance Method Summary collapse

Methods inherited from Any

#initialize

Constructor Details

This class inherits a constructor from XDG::Paths::Any

Instance Method Details

#defaultObject



9
# File 'lib/xdg/paths/directory.rb', line 9

def default = value.split(DELIMITER).map { |path| expand path }

#dynamicObject



11
12
13
14
15
16
# File 'lib/xdg/paths/directory.rb', line 11

def dynamic
  String(environment[key]).then { |env_value| env_value.empty? ? value : env_value }
                          .split(DELIMITER)
                          .uniq
                          .map { |path| expand path }
end

#inspectObject



22
23
24
25
26
27
# File 'lib/xdg/paths/directory.rb', line 22

def inspect
  pairs = to_s
  type = self.class

  pairs.empty? ? "#<#{type}:#{object_id}>" : "#<#{type}:#{object_id} #{self}>"
end

#keyObject



29
# File 'lib/xdg/paths/directory.rb', line 29

def key = String pair.key

#to_sObject Also known as: to_str



18
# File 'lib/xdg/paths/directory.rb', line 18

def to_s = [key, dynamic.join(DELIMITER)].reject(&:empty?).join XDG::DELIMITER

#valueObject



31
# File 'lib/xdg/paths/directory.rb', line 31

def value = String pair.value