Sha256: a9605f38a6e6c19659aa5e10cc33ccf10ccdce6f848b79dadfde861672e74bd4

Contents?: true

Size: 757 Bytes

Versions: 11

Compression:

Stored size: 757 Bytes

Contents

# frozen_string_literal: true

require "forwardable"
require "pathname"

module Runcom
  module Paths
    # Provides common path/functionality for all XDG enhanced objects.
    class Common
      extend Forwardable

      delegate %i[inspect] => :xdg

      attr_reader :relative

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

      def namespace
        relative.parent
      end

      def file_name
        relative.basename
      end

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

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

      private

      attr_reader :context

      def xdg
        context.xdg
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
runcom-7.1.0 lib/runcom/paths/common.rb
runcom-7.0.0 lib/runcom/paths/common.rb
runcom-6.6.0 lib/runcom/paths/common.rb
runcom-6.5.0 lib/runcom/paths/common.rb
runcom-6.4.0 lib/runcom/paths/common.rb
runcom-6.3.0 lib/runcom/paths/common.rb
runcom-6.2.0 lib/runcom/paths/common.rb
runcom-6.1.1 lib/runcom/paths/common.rb
runcom-6.1.0 lib/runcom/paths/common.rb
runcom-6.0.1 lib/runcom/paths/common.rb
runcom-6.0.0 lib/runcom/paths/common.rb