Class: AssetDB::Asset
- Inherits:
-
Object
- Object
- AssetDB::Asset
- Defined in:
- lib/asset_db/asset.rb
Instance Attribute Summary collapse
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#package ⇒ Object
readonly
Returns the value of attribute package.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(type:, group:, package:, url:, metadata: nil, id: url) ⇒ Asset
constructor
A new instance of Asset.
- #protocol_url? ⇒ Boolean
Constructor Details
#initialize(type:, group:, package:, url:, metadata: nil, id: url) ⇒ Asset
Returns a new instance of Asset.
9 10 11 12 13 14 15 16 |
# File 'lib/asset_db/asset.rb', line 9 def initialize(type:, group:, package:, url:, metadata: nil, id: url) @type = type.to_sym @url = url.to_s.freeze @metadata = @id = id.to_s.freeze @package = package @group = group end |
Instance Attribute Details
#group ⇒ Object (readonly)
Returns the value of attribute group.
7 8 9 |
# File 'lib/asset_db/asset.rb', line 7 def group @group end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/asset_db/asset.rb', line 7 def id @id end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
7 8 9 |
# File 'lib/asset_db/asset.rb', line 7 def @metadata end |
#package ⇒ Object (readonly)
Returns the value of attribute package.
7 8 9 |
# File 'lib/asset_db/asset.rb', line 7 def package @package end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/asset_db/asset.rb', line 7 def type @type end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/asset_db/asset.rb', line 7 def url @url end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
18 19 20 |
# File 'lib/asset_db/asset.rb', line 18 def ==(other) other.is_a?(Asset) && other.id == id end |
#hash ⇒ Object
23 24 25 |
# File 'lib/asset_db/asset.rb', line 23 def hash id.hash end |
#protocol_url? ⇒ Boolean
27 28 29 |
# File 'lib/asset_db/asset.rb', line 27 def protocol_url? @protocol ||= url =~ /\A[A-Za-z][A-Za-z0-9+\-.]*:\/\// end |