Class: Runcom::Paths::Common

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

Overview

Provides common path/functionality for all XDG enhanced objects.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(relative, context: Context.new) ⇒ Common

Returns a new instance of Common.



16
17
18
19
# File 'lib/runcom/paths/common.rb', line 16

def initialize relative, context: Context.new
  @relative = Pathname relative
  @context = context
end

Instance Attribute Details

#relativeObject (readonly)

Returns the value of attribute relative.



14
15
16
# File 'lib/runcom/paths/common.rb', line 14

def relative
  @relative
end

Instance Method Details

#allObject



33
34
35
# File 'lib/runcom/paths/common.rb', line 33

def all
  xdg.all.map { |root| root.join relative }
end

#currentObject



29
30
31
# File 'lib/runcom/paths/common.rb', line 29

def current
  all.find(&:exist?)
end

#file_nameObject



25
26
27
# File 'lib/runcom/paths/common.rb', line 25

def file_name
  relative.basename
end

#namespaceObject



21
22
23
# File 'lib/runcom/paths/common.rb', line 21

def namespace
  relative.parent
end