Class: Morion::File
- Inherits:
-
Object
- Object
- Morion::File
- Defined in:
- lib/morion/file.rb
Constant Summary collapse
- FILENAME_REGEX =
/(?:.+\/)([^#?]+)/- EXTENSION_REGEX =
/\.[^.]*$/
Instance Method Summary collapse
- #asset_path ⇒ Object
- #extension ⇒ Object
- #filename ⇒ Object
- #folder_path ⇒ Object
-
#initialize(path, assets_paths, rails_root) ⇒ File
constructor
A new instance of File.
Constructor Details
#initialize(path, assets_paths, rails_root) ⇒ File
Returns a new instance of File.
6 7 8 9 10 |
# File 'lib/morion/file.rb', line 6 def initialize(path, assets_paths, rails_root) @path = path @assets_paths = assets_paths @rails_root = rails_root end |
Instance Method Details
#asset_path ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/morion/file.rb', line 20 def asset_path file_path = @path @assets_paths.each do |rails_path| file_path = file_path.gsub("#{rails_path}/", "") end file_path end |
#extension ⇒ Object
16 17 18 |
# File 'lib/morion/file.rb', line 16 def extension filename.match(EXTENSION_REGEX)[1] end |
#filename ⇒ Object
12 13 14 |
# File 'lib/morion/file.rb', line 12 def filename @path.match(FILENAME_REGEX)[1] end |
#folder_path ⇒ Object
30 31 32 |
# File 'lib/morion/file.rb', line 30 def folder_path @path.gsub(@rails_root, "").match(/(.*)\/.*/)[1] end |