Class: HerokuErrorPages::PublicAsset

Inherits:
Object
  • Object
show all
Defined in:
lib/heroku_error_pages/public_asset.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_pathObject (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

.allObject



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_typeObject



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_pathObject



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