Sha256: 609541cdb3de6cd70aa125734a3d3c9200b5d1b81363b9e8018d743c4579c0c8

Contents?: true

Size: 1.05 KB

Versions: 263

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module Avm
  module Launcher
    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)
          ::Avm::Launcher::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
end

Version data entries

263 entries across 263 versions & 3 rubygems

Version Path
eac_tools-0.76.0 sub/avm/lib/avm/launcher/paths/real.rb
eac_tools-0.75.2 sub/avm/lib/avm/launcher/paths/real.rb
eac_tools-0.75.1 sub/avm/lib/avm/launcher/paths/real.rb
eac_tools-0.75.0 sub/avm/lib/avm/launcher/paths/real.rb
eac_tools-0.74.1 sub/avm/lib/avm/launcher/paths/real.rb
eac_tools-0.74.0 sub/avm/lib/avm/launcher/paths/real.rb
avm-0.79.0 lib/avm/launcher/paths/real.rb
eac_tools-0.73.0 sub/avm/lib/avm/launcher/paths/real.rb
eac_tools-0.72.0 sub/avm/lib/avm/launcher/paths/real.rb
avm-0.78.0 lib/avm/launcher/paths/real.rb
eac_tools-0.70.1 sub/avm/lib/avm/launcher/paths/real.rb
avm-0.77.0 lib/avm/launcher/paths/real.rb
eac_tools-0.70.0 sub/avm/lib/avm/launcher/paths/real.rb
avm-0.76.0 lib/avm/launcher/paths/real.rb
eac_tools-0.69.1 sub/avm/lib/avm/launcher/paths/real.rb
avm-0.75.0 lib/avm/launcher/paths/real.rb
eac_tools-0.69.0 sub/avm/lib/avm/launcher/paths/real.rb
avm-0.74.0 lib/avm/launcher/paths/real.rb
eac_tools-0.68.0 sub/avm/lib/avm/launcher/paths/real.rb
avm-0.73.1 lib/avm/launcher/paths/real.rb