Class: XDG::Paths::Directory
- Inherits:
-
Object
- Object
- XDG::Paths::Directory
- Defined in:
- lib/xdg/paths/directory.rb
Overview
A collection of XDG directories.
Constant Summary collapse
- DELIMITER =
":"
Instance Method Summary collapse
- #default ⇒ Object
- #dynamic ⇒ Object
-
#initialize(pair, environment = ENV) ⇒ Directory
constructor
A new instance of Directory.
- #inspect ⇒ Object
- #to_s ⇒ Object (also: #to_str)
Constructor Details
#initialize(pair, environment = ENV) ⇒ Directory
Returns a new instance of Directory.
11 12 13 14 15 |
# File 'lib/xdg/paths/directory.rb', line 11 def initialize pair, environment = ENV @pair = pair @environment = environment freeze end |
Instance Method Details
#default ⇒ Object
17 |
# File 'lib/xdg/paths/directory.rb', line 17 def default = value.split(DELIMITER).map { |path| path } |
#dynamic ⇒ Object
19 20 21 22 23 24 |
# File 'lib/xdg/paths/directory.rb', line 19 def dynamic String(environment[key]).then { |env_value| env_value.empty? ? value : env_value } .split(DELIMITER) .uniq .map { |path| path } end |
#inspect ⇒ Object
30 31 32 33 34 35 |
# File 'lib/xdg/paths/directory.rb', line 30 def inspect pairs = to_s type = self.class pairs.empty? ? "#<#{type}:#{object_id}>" : "#<#{type}:#{object_id} #{self}>" end |
#to_s ⇒ Object Also known as: to_str
26 |
# File 'lib/xdg/paths/directory.rb', line 26 def to_s = [key, dynamic.join(DELIMITER)].reject(&:empty?).join XDG::DELIMITER |