Sha256: 2a7d7a18c93949fa7f96ad0609069b260022215173561d5fcde5e267a0669301
Contents?: true
Size: 817 Bytes
Versions: 1
Compression:
Stored size: 817 Bytes
Contents
# frozen_string_literal: true require "forwardable" require "pathname" module XDG module Paths # A XDG home path. class Home extend Forwardable KEY = "HOME" delegate %i[key value] => :pair def initialize pair, environment = ENV @pair = pair @environment = environment freeze end def default = expand String(value) def dynamic = String(environment[key]).then { |path| path.empty? ? default : expand(path) } def to_s = [pair.key, dynamic].compact.join XDG::DELIMITER alias to_str to_s def inspect = "#<#{self.class}:#{object_id} #{self}>" private attr_reader :pair, :environment def expand(path) = home.join(path).expand_path def home = Pathname environment.fetch(KEY) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
xdg-9.0.0 | lib/xdg/paths/home.rb |