Class: Lifer::Asset
- Inherits:
-
Object
- Object
- Lifer::Asset
- Defined in:
- lib/lifer/asset.rb
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
-
#url(host: self.class.default_host) ⇒ String
readonly
Gets the current URL.
Class Method Summary collapse
-
.build_or_update(url: nil, entries: []) ⇒ Lifer::Asset
Builds or updates a Lifer asset.
-
.default_host ⇒ String
The default host for all assets.
Instance Method Summary collapse
-
#initialize(url:, entries:) ⇒ Asset
constructor
A new instance of Asset.
-
#match?(url:, host: self.class.default_host) ⇒ boolean
Checks whether a given URL matches the current asset’s URL.
Constructor Details
#initialize(url:, entries:) ⇒ Asset
Returns a new instance of Asset.
51 52 53 54 55 56 57 58 |
# File 'lib/lifer/asset.rb', line 51 def initialize(url:, entries:) normalized_url = Lifer::Utilities.uri_from url, host: self.class.default_host, object_type: self @url = normalized_url @entries = entries end |
Instance Attribute Details
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
49 50 51 |
# File 'lib/lifer/asset.rb', line 49 def entries @entries end |
#url(host: self.class.default_host) ⇒ String (readonly)
Gets the current URL. If given a host, the asset’s true host will be replaced with the given host.
75 76 77 |
# File 'lib/lifer/asset.rb', line 75 def url @url end |
Class Method Details
.build_or_update(url: nil, entries: []) ⇒ Lifer::Asset
Builds or updates a Lifer asset. On update, this list of an asset’s entries would get freshened.
17 18 19 |
# File 'lib/lifer/asset.rb', line 17 def build_or_update(url: nil, entries: []) update(url:, entries:) || build(url:, entries:) end |