Class: Lapis::Minecraft::Versioning::AssetIndex

Inherits:
Object
  • Object
show all
Defined in:
lib/lapis/minecraft/versioning/asset_index.rb

Overview

Note:

This class isn't used directly for accessing asset instances. It is used for retrieving information about assets.

Container for tracking information about assets.

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, sha1, size, url, total_size) ⇒ AssetIndex

Creates an asset index.

Parameters:

  • id (String)

    Unique name of the collection of assets.

  • sha1 (String)

    SHA1 hash of the asset list document in hexadecimal.

  • size (Fixnum)

    Size of the asset list document in bytes.

  • url (String)

    Location of where the asset list document can be found.

  • total_size (Fixnum)

    Total size of all the assets combined.


37
38
39
40
41
42
43
# File 'lib/lapis/minecraft/versioning/asset_index.rb', line 37

def initialize(id, sha1, size, url, total_size)
  @id         = id.dup.freeze
  @sha1       = sha1.dup.freeze
  @size       = size
  @url        = url.dup.freeze
  @total_size = total_size
end

Instance Attribute Details

#idString (readonly)

Unique name of the collection of assets.

Returns:

  • (String)

13
14
15
# File 'lib/lapis/minecraft/versioning/asset_index.rb', line 13

def id
  @id
end

#sha1String (readonly)

SHA1 hash of the asset list document in hexadecimal.

Returns:

  • (String)

17
18
19
# File 'lib/lapis/minecraft/versioning/asset_index.rb', line 17

def sha1
  @sha1
end

#sizeFixnum (readonly)

Size of the asset list document in bytes.

Returns:

  • (Fixnum)

21
22
23
# File 'lib/lapis/minecraft/versioning/asset_index.rb', line 21

def size
  @size
end

#total_sizeFixnum (readonly)

Total size of all the assets combined.

Returns:

  • (Fixnum)

29
30
31
# File 'lib/lapis/minecraft/versioning/asset_index.rb', line 29

def total_size
  @total_size
end

#urlString (readonly)

Location of where the asset list document can be found.

Returns:

  • (String)

25
26
27
# File 'lib/lapis/minecraft/versioning/asset_index.rb', line 25

def url
  @url
end

Instance Method Details

#==(other) ⇒ true, false

Compares one asset index to another.

Parameters:

  • other (AssetIndex)

    Asset index to compare against.

Returns:

  • (true)

    The asset indices are the same.

  • (false)

    The asset indices are different.


49
50
51
52
53
54
55
# File 'lib/lapis/minecraft/versioning/asset_index.rb', line 49

def ==(other)
  other.id == @id &&
      other.sha1 == @sha1 &&
      other.size == @size &&
      other.url == @url &&
      other.total_size == @total_size
end