Class: Hanami::Assets::Asset
- Inherits:
-
Object
- Object
- Hanami::Assets::Asset
- Defined in:
- lib/hanami/assets/asset.rb
Overview
Represents a single front end asset.
Instance Attribute Summary collapse
-
#path ⇒ String
readonly
Returns the asset’s absolute URL path.
-
#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) ⇒ 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) ⇒ 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.
44 45 46 47 48 |
# File 'lib/hanami/assets/asset.rb', line 44 def initialize(path:, base_url:, sri: nil) @path = path @base_url = base_url @sri = sri end |
Instance Attribute Details
#path ⇒ String (readonly)
Returns the asset’s absolute URL path.
27 28 29 |
# File 'lib/hanami/assets/asset.rb', line 27 def path @path 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/assets/asset.rb', line 40 def sri @sri end |
Instance Method Details
#to_s ⇒ String
Returns the asset’s full URL
78 79 80 |
# File 'lib/hanami/assets/asset.rb', line 78 def to_s url end |
#url ⇒ String
Returns the asset’s full URL.
66 67 68 |
# File 'lib/hanami/assets/asset.rb', line 66 def url base_url.join(path) end |