Sha256: c894b2fb39d8f605750396366b986050e12a23e513a06ac6fdd59f9faf9513ae
Contents?: true
Size: 754 Bytes
Versions: 3
Compression:
Stored size: 754 Bytes
Contents
# frozen_string_literal: true require "forwardable" require "pathname" module XDG module Paths # A XDG home path. class Standard extend Forwardable HOME_KEY = "HOME" delegate %i[key value] => :pair def initialize pair, environment = ENV @pair = pair @environment = environment end def default expand_home_for String(value) end def dynamic String(environment[key]).then { |path| path.empty? ? default : expand_home_for(path) } end private attr_reader :pair, :environment def home Pathname environment.fetch(HOME_KEY) end def expand_home_for path home.join(path).expand_path end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
xdg-3.0.2 | lib/xdg/paths/standard.rb |
xdg-3.0.1 | lib/xdg/paths/standard.rb |
xdg-3.0.0 | lib/xdg/paths/standard.rb |