Sha256: ed18e6e425f2170e89390d8cf77f82b45fccc73d11ff803f4ca3d673b43c391f

Contents?: true

Size: 742 Bytes

Versions: 13

Compression:

Stored size: 742 Bytes

Contents

# frozen_string_literal: true

require "forwardable"
require "refinements/pathnames"

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

      using Refinements::Pathnames

      delegate %i[inspect] => :xdg

      attr_reader :relative

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

      def namespace = relative.parent

      def file_name = relative.basename

      def current = all.select(&:file?).find(&:exist?)

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

      private

      attr_reader :context

      def xdg = context.xdg
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
runcom-9.0.3 lib/runcom/paths/common.rb
runcom-9.0.2 lib/runcom/paths/common.rb
runcom-9.0.1 lib/runcom/paths/common.rb
runcom-9.0.0 lib/runcom/paths/common.rb
runcom-8.7.0 lib/runcom/paths/common.rb
runcom-8.6.0 lib/runcom/paths/common.rb
runcom-8.5.0 lib/runcom/paths/common.rb
runcom-8.4.0 lib/runcom/paths/common.rb
runcom-8.3.3 lib/runcom/paths/common.rb
runcom-8.3.2 lib/runcom/paths/common.rb
runcom-8.3.1 lib/runcom/paths/common.rb
runcom-8.3.0 lib/runcom/paths/common.rb
runcom-8.2.0 lib/runcom/paths/common.rb