Class: Morion::FileRef
- Inherits:
-
Object
- Object
- Morion::FileRef
- Defined in:
- lib/morion/file_ref.rb
Constant Summary collapse
- FILENAME_REGEX =
%r{(?:.+/)([^#?]+)}.freeze
- EXTENSION_REGEX =
/\.[^.]*$/.freeze
Instance Attribute Summary collapse
-
#extension ⇒ Object
Returns the value of attribute extension.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#folder_path ⇒ Object
Returns the value of attribute folder_path.
-
#path ⇒ Object
Returns the value of attribute path.
-
#relative_path ⇒ Object
Returns the value of attribute relative_path.
Instance Method Summary collapse
-
#initialize(path, current_path) ⇒ FileRef
constructor
A new instance of FileRef.
Constructor Details
#initialize(path, current_path) ⇒ FileRef
Returns a new instance of FileRef.
8 9 10 11 12 13 14 15 |
# File 'lib/morion/file_ref.rb', line 8 def initialize(path, current_path) @path = path @current_path = current_path @filename = @path.match(FILENAME_REGEX)[1] @extension = filename.match(EXTENSION_REGEX)[0] @relative_path = @path.gsub(@current_path, '') @folder_path = @relative_path.match(%r{(.*)/.*})[1] end |
Instance Attribute Details
#extension ⇒ Object
Returns the value of attribute extension.
6 7 8 |
# File 'lib/morion/file_ref.rb', line 6 def extension @extension end |
#filename ⇒ Object
Returns the value of attribute filename.
6 7 8 |
# File 'lib/morion/file_ref.rb', line 6 def filename @filename end |
#folder_path ⇒ Object
Returns the value of attribute folder_path.
6 7 8 |
# File 'lib/morion/file_ref.rb', line 6 def folder_path @folder_path end |
#path ⇒ Object
Returns the value of attribute path.
6 7 8 |
# File 'lib/morion/file_ref.rb', line 6 def path @path end |
#relative_path ⇒ Object
Returns the value of attribute relative_path.
6 7 8 |
# File 'lib/morion/file_ref.rb', line 6 def relative_path @relative_path end |