Class: Lapis::Minecraft::Versioning::Asset

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

Overview

Information about a content file needed for the client.

Direct Known Subclasses

Resource

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(size, sha1, path) ⇒ Asset

Creates information about an asset.

Parameters:

  • size (Fixnum)

    Size of the asset in bytes.

  • sha1 (String)

    SHA1 hash of the asset’s contents in hexadecimal.

  • path (String, nil)

    Path, relative to the installation directory, to store the asset.



24
25
26
27
28
# File 'lib/lapis/minecraft/versioning/asset.rb', line 24

def initialize(size, sha1, path)
  @size = size
  @sha1 = sha1.dup.freeze
  @path = path ? path.dup.freeze : nil
end

Instance Attribute Details

#pathString? (readonly)

Path, relative to the installation directory, to store the asset.

Returns:

  • (String, nil)

    Relative path or nil if the asset can be placed anywhere.



18
19
20
# File 'lib/lapis/minecraft/versioning/asset.rb', line 18

def path
  @path
end

#sha1String (readonly)

SHA1 hash of the asset’s contents in hexadecimal.

Returns:

  • (String)


14
15
16
# File 'lib/lapis/minecraft/versioning/asset.rb', line 14

def sha1
  @sha1
end

#sizeFixnum (readonly)

Size of the asset in bytes.

Returns:

  • (Fixnum)


10
11
12
# File 'lib/lapis/minecraft/versioning/asset.rb', line 10

def size
  @size
end

Instance Method Details

#==(other) ⇒ true, false

Compares one asset to another.

Parameters:

  • other (Asset)

    Asset to compare against.

Returns:

  • (true)

    The assets are the same.

  • (false)

    The assets are different.



34
35
36
37
38
# File 'lib/lapis/minecraft/versioning/asset.rb', line 34

def ==(other)
  other.size == @size &&
      other.sha1 == @sha1 &&
      other.path == @path
end