Class: HerokuErrorPages::PublicAsset
- Inherits:
-
Object
- Object
- HerokuErrorPages::PublicAsset
- Defined in:
- lib/heroku_error_pages/public_asset.rb
Instance Attribute Summary collapse
-
#absolute_path ⇒ Object
readonly
Returns the value of attribute absolute_path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(absolute_path) ⇒ PublicAsset
constructor
A new instance of PublicAsset.
- #mime_type ⇒ Object
- #relative_path ⇒ Object
Constructor Details
#initialize(absolute_path) ⇒ PublicAsset
Returns a new instance of PublicAsset.
15 16 17 |
# File 'lib/heroku_error_pages/public_asset.rb', line 15 def initialize(absolute_path) @absolute_path = absolute_path end |
Instance Attribute Details
#absolute_path ⇒ Object (readonly)
Returns the value of attribute absolute_path.
13 14 15 |
# File 'lib/heroku_error_pages/public_asset.rb', line 13 def absolute_path @absolute_path end |
Class Method Details
.all ⇒ Object
6 7 8 9 10 |
# File 'lib/heroku_error_pages/public_asset.rb', line 6 def all Dir.glob(Rails.public_path.join("*", "**")).map do |absolute_path| new(absolute_path) end end |
Instance Method Details
#mime_type ⇒ Object
23 24 25 26 |
# File 'lib/heroku_error_pages/public_asset.rb', line 23 def mime_type extension = File.extname(absolute_path).strip.downcase[1..] Mime::Type.lookup_by_extension(extension)&.to_s end |
#relative_path ⇒ Object
19 20 21 |
# File 'lib/heroku_error_pages/public_asset.rb', line 19 def relative_path @relative_path ||= Pathname.new(absolute_path).relative_path_from(Rails.public_path).to_s end |