Class: AssetDB::Asset

Inherits:
Object
  • Object
show all
Defined in:
lib/asset_db/asset.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#groupObject (readonly)

Returns the value of attribute group.



7
8
9
# File 'lib/asset_db/asset.rb', line 7

def group
  @group
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/asset_db/asset.rb', line 7

def id
  @id
end

#metadataObject (readonly)

Returns the value of attribute metadata.



7
8
9
# File 'lib/asset_db/asset.rb', line 7

def 
  @metadata
end

#packageObject (readonly)

Returns the value of attribute package.



7
8
9
# File 'lib/asset_db/asset.rb', line 7

def package
  @package
end

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/asset_db/asset.rb', line 7

def type
  @type
end

#urlObject (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

#hashObject



23
24
25
# File 'lib/asset_db/asset.rb', line 23

def hash
	id.hash
end

#protocol_url?Boolean

Returns:

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