Class: Avm::Launcher::Paths::Real

Inherits:
String
  • Object
show all
Defined in:
lib/avm/launcher/paths/real.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Real

Returns a new instance of Real.



7
8
9
10
11
# File 'lib/avm/launcher/paths/real.rb', line 7

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

  super
end

Instance Method Details

#basenameObject



17
18
19
# File 'lib/avm/launcher/paths/real.rb', line 17

def basename
  ::File.basename(self)
end

#dirnameObject



21
22
23
24
25
# File 'lib/avm/launcher/paths/real.rb', line 21

def dirname
  return nil if self == '/'

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

#find_file_with_extension(extension) ⇒ Object



27
28
29
30
31
32
# File 'lib/avm/launcher/paths/real.rb', line 27

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

#find_files_with_extension(extension) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/avm/launcher/paths/real.rb', line 34

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

#subpath(relative_path) ⇒ Object



13
14
15
# File 'lib/avm/launcher/paths/real.rb', line 13

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