Class: FileName
- Inherits:
-
Object
- Object
- FileName
- Defined in:
- lib/models/files/file_name.rb
Instance Attribute Summary collapse
-
#dirname ⇒ Object
readonly
Returns the value of attribute dirname.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #extname ⇒ Object
-
#initialize(path) ⇒ FileName
constructor
A new instance of FileName.
- #name ⇒ Object
- #no_dir? ⇒ Boolean
Constructor Details
#initialize(path) ⇒ FileName
Returns a new instance of FileName.
3 4 5 6 |
# File 'lib/models/files/file_name.rb', line 3 def initialize(path) @path = path @dirname, @filename = File.split(path) end |
Instance Attribute Details
#dirname ⇒ Object (readonly)
Returns the value of attribute dirname.
2 3 4 |
# File 'lib/models/files/file_name.rb', line 2 def dirname @dirname end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
2 3 4 |
# File 'lib/models/files/file_name.rb', line 2 def filename @filename end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
2 3 4 |
# File 'lib/models/files/file_name.rb', line 2 def path @path end |
Instance Method Details
#extname ⇒ Object
8 9 10 |
# File 'lib/models/files/file_name.rb', line 8 def extname File.extname(@filename) end |
#name ⇒ Object
12 13 14 |
# File 'lib/models/files/file_name.rb', line 12 def name File.basename(@filename, '.*') end |
#no_dir? ⇒ Boolean
16 17 18 |
# File 'lib/models/files/file_name.rb', line 16 def no_dir? return @dirname == '.' end |