Class: Avm::Launcher::Paths::Real
- Inherits:
-
String
- Object
- String
- Avm::Launcher::Paths::Real
- Defined in:
- lib/avm/launcher/paths/real.rb
Instance Method Summary collapse
- #basename ⇒ Object
- #dirname ⇒ Object
- #find_file_with_extension(extension) ⇒ Object
- #find_files_with_extension(extension) ⇒ Object
-
#initialize(path) ⇒ Real
constructor
A new instance of Real.
- #subpath(relative_path) ⇒ Object
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
#basename ⇒ Object
17 18 19 |
# File 'lib/avm/launcher/paths/real.rb', line 17 def basename ::File.basename(self) end |
#dirname ⇒ Object
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.(i, self) if i =~ /#{::Regexp.quote(extension)}\z/ end r end |