Sha256: fc9b71fbf9d745a32ff958b6ff771537b73b2c5d5c31e2f5e0fa7c87aa33acec

Contents?: true

Size: 994 Bytes

Versions: 87

Compression:

Stored size: 994 Bytes

Contents

# frozen_string_literal: true

module EacLauncher
  module Paths
    class Real < String
      def initialize(path)
        raise "Argument path is not a string: \"#{path}\"|#{path.class}" unless path.is_a?(String)

        super(path)
      end

      def subpath(relative_path)
        ::EacLauncher::Paths::Real.new(::File.expand_path(relative_path, self))
      end

      def basename
        ::File.basename(self)
      end

      def dirname
        return nil if self == '/'

        self.class.new(::File.dirname(self))
      end

      def find_file_with_extension(extension)
        r = find_files_with_extension(extension)
        return r.first if r.any?

        raise "Extension \"#{extension}\" not found in directory \"#{self}\""
      end

      def find_files_with_extension(extension)
        r = []
        ::Dir.entries(self).each do |i|
          r << ::File.expand_path(i, self) if i =~ /#{::Regexp.quote(extension)}\z/
        end
        r
      end
    end
  end
end

Version data entries

87 entries across 87 versions & 2 rubygems

Version Path
avm-tools-0.99.0 lib/eac_launcher/paths/real.rb
avm-tools-0.98.0 lib/eac_launcher/paths/real.rb
avm-tools-0.97.0 lib/eac_launcher/paths/real.rb
avm-tools-0.96.0 lib/eac_launcher/paths/real.rb
avm-tools-0.95.0 lib/eac_launcher/paths/real.rb
avm-tools-0.94.3 lib/eac_launcher/paths/real.rb
avm-tools-0.94.2 lib/eac_launcher/paths/real.rb
avm-tools-0.94.1 lib/eac_launcher/paths/real.rb
avm-tools-0.94.0 lib/eac_launcher/paths/real.rb
avm-tools-0.93.0 lib/eac_launcher/paths/real.rb
avm-tools-0.92.0 lib/eac_launcher/paths/real.rb
avm-tools-0.91.0 lib/eac_launcher/paths/real.rb
avm-tools-0.90.0 lib/eac_launcher/paths/real.rb
avm-tools-0.89.0 lib/eac_launcher/paths/real.rb
avm-tools-0.88.0 lib/eac_launcher/paths/real.rb
avm-tools-0.87.1 lib/eac_launcher/paths/real.rb
avm-tools-0.87.0 lib/eac_launcher/paths/real.rb
avm-tools-0.86.0 lib/eac_launcher/paths/real.rb
avm-tools-0.85.1 lib/eac_launcher/paths/real.rb
avm-tools-0.85.0 lib/eac_launcher/paths/real.rb