Class: Hanami::Assets::Asset
- Inherits:
-
Object
- Object
- Hanami::Assets::Asset
- Defined in:
- lib/hanami/sprockets/asset.rb
Overview
Represents a single front end asset.
Instance Attribute Summary collapse
-
#content_type ⇒ String
readonly
Returns the asset’s content type.
-
#digest_path ⇒ String
readonly
Returns the asset’s digest path (fingerprinted path).
-
#logical_path ⇒ String
readonly
Returns the asset’s logical path (original path without fingerprinting).
-
#path ⇒ String
readonly
Returns the asset’s absolute URL path.
-
#source ⇒ String
readonly
Returns the asset’s source content.
-
#sri ⇒ String?
(also: #subresource_integrity_value)
readonly
Returns the asset’s subresource integrity value, or nil if none is available.
Instance Method Summary collapse
-
#initialize(path:, base_url:, sri: nil, logical_path: nil, digest_path: nil, content_type: nil, source: nil) ⇒ Asset
constructor
private
A new instance of Asset.
-
#to_s ⇒ String
Returns the asset’s full URL.
-
#url ⇒ String
Returns the asset’s full URL.
Constructor Details
#initialize(path:, base_url:, sri: nil, logical_path: nil, digest_path: nil, content_type: nil, source: nil) ⇒ Asset
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Asset.
76 77 78 79 80 81 82 83 84 |
# File 'lib/hanami/sprockets/asset.rb', line 76 def initialize(path:, base_url:, sri: nil, logical_path: nil, digest_path: nil, content_type: nil, source: nil) @path = path @base_url = base_url @sri = sri @logical_path = logical_path @digest_path = digest_path @content_type = content_type @source = source end |
Instance Attribute Details
#content_type ⇒ String (readonly)
Returns the asset’s content type
64 65 66 |
# File 'lib/hanami/sprockets/asset.rb', line 64 def content_type @content_type end |
#digest_path ⇒ String (readonly)
Returns the asset’s digest path (fingerprinted path)
56 57 58 |
# File 'lib/hanami/sprockets/asset.rb', line 56 def digest_path @digest_path end |
#logical_path ⇒ String (readonly)
Returns the asset’s logical path (original path without fingerprinting)
48 49 50 |
# File 'lib/hanami/sprockets/asset.rb', line 48 def logical_path @logical_path end |
#path ⇒ String (readonly)
Returns the asset’s absolute URL path.
27 28 29 |
# File 'lib/hanami/sprockets/asset.rb', line 27 def path @path end |
#source ⇒ String (readonly)
Returns the asset’s source content
72 73 74 |
# File 'lib/hanami/sprockets/asset.rb', line 72 def source @source end |
#sri ⇒ String? (readonly) Also known as: subresource_integrity_value
Returns the asset’s subresource integrity value, or nil if none is available.
40 41 42 |
# File 'lib/hanami/sprockets/asset.rb', line 40 def sri @sri end |
Instance Method Details
#to_s ⇒ String
Returns the asset’s full URL
114 115 116 |
# File 'lib/hanami/sprockets/asset.rb', line 114 def to_s url end |
#url ⇒ String
Returns the asset’s full URL.
102 103 104 |
# File 'lib/hanami/sprockets/asset.rb', line 102 def url base_url.join(path) end |