Class: XDG::Paths::Home

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/xdg/paths/home.rb

Overview

A XDG home path.

Constant Summary collapse

KEY =
"HOME"

Instance Method Summary collapse

Constructor Details

#initialize(pair, environment = ENV) ⇒ Home

Returns a new instance of Home.



16
17
18
19
# File 'lib/xdg/paths/home.rb', line 16

def initialize pair, environment = ENV
  @pair = pair
  @environment = environment
end

Instance Method Details

#defaultObject



21
# File 'lib/xdg/paths/home.rb', line 21

def default = expand String(value)

#dynamicObject



23
# File 'lib/xdg/paths/home.rb', line 23

def dynamic = String(environment[key]).then { |path| path.empty? ? default : expand(path) }

#inspectObject



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

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

#to_sObject Also known as: to_str



25
# File 'lib/xdg/paths/home.rb', line 25

def to_s = [pair.key, dynamic].compact.join XDG::DELIMITER