Class: EacLauncher::Paths::Real

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

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Real

Returns a new instance of Real.



6
7
8
9
10
# File 'lib/eac_launcher/paths/real.rb', line 6

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

  super(path)
end

Instance Method Details

#basenameObject



16
17
18
# File 'lib/eac_launcher/paths/real.rb', line 16

def basename
  ::File.basename(self)
end

#dirnameObject



20
21
22
23
24
# File 'lib/eac_launcher/paths/real.rb', line 20

def dirname
  return nil if self == '/'

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

#find_file_with_extension(extension) ⇒ Object



26
27
28
29
30
31
# File 'lib/eac_launcher/paths/real.rb', line 26

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



33
34
35
36
37
38
39
# File 'lib/eac_launcher/paths/real.rb', line 33

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



12
13
14
# File 'lib/eac_launcher/paths/real.rb', line 12

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