Class: SingleFile
- Inherits:
-
Object
- Object
- SingleFile
- Defined in:
- lib/file_obj.rb
Overview
Global file objects $file and $files
Instance Attribute Summary collapse
-
#path ⇒ Object
Full file path e.g.
Instance Method Summary collapse
-
#dir ⇒ Object
the directory of the file e.g.
-
#ext ⇒ Object
the file extension.
-
#full_name ⇒ Object
the file name and extension.
-
#initialize(path) ⇒ SingleFile
constructor
A new instance of SingleFile.
-
#name ⇒ Object
the name of the file, without extension.
-
#to_s ⇒ Object
will return path.
Constructor Details
#initialize(path) ⇒ SingleFile
Returns a new instance of SingleFile.
7 8 9 |
# File 'lib/file_obj.rb', line 7 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object
Full file path e.g. “src/main.c”
5 6 7 |
# File 'lib/file_obj.rb', line 5 def path @path end |
Instance Method Details
#dir ⇒ Object
the directory of the file e.g. if the file is “src/main.c”, dir will be “src”
28 29 30 |
# File 'lib/file_obj.rb', line 28 def dir File.dirname(@path) end |
#ext ⇒ Object
the file extension
22 23 24 |
# File 'lib/file_obj.rb', line 22 def ext File.extname(@path) end |
#full_name ⇒ Object
the file name and extension
17 18 19 |
# File 'lib/file_obj.rb', line 17 def full_name File.basename(@path) end |
#name ⇒ Object
the name of the file, without extension
12 13 14 |
# File 'lib/file_obj.rb', line 12 def name File.basename(@path, ".*") end |
#to_s ⇒ Object
will return path
33 34 35 |
# File 'lib/file_obj.rb', line 33 def to_s @path end |