Class: Lapis::Minecraft::Versioning::Resource

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

Overview

Information about a resource (file) to download as part of the client or server.

Instance Attribute Summary collapse

Attributes inherited from Asset

#path, #sha1, #size

Instance Method Summary collapse

Constructor Details

#initialize(url, size, sha1, path = nil, classifier = nil) ⇒ Resource

Creates information about a resource.

Parameters:

  • url (String)

    URL where the resource can be found and downloaded from.

  • size (Fixnum)

    Size of the resource in bytes.

  • sha1 (String)

    SHA1 hash of the resource's contents in hexadecimal.

  • path (String, nil) (defaults to: nil)

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

  • classifier (String, nil) (defaults to: nil)

    Logical category the resource falls under.


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

def initialize(url, size, sha1, path = nil, classifier = nil)
  super(size, sha1, path)
  @url        = url.dup.freeze
  @classifier = classifier.dup.freeze
end

Instance Attribute Details

#classifierString? (readonly)

Logical category the resource falls under.

Returns:

  • (String, nil)

    Name of the category or nil if the resource doesn't have one.


16
17
18
# File 'lib/lapis/minecraft/versioning/resource.rb', line 16

def classifier
  @classifier
end

#urlString (readonly)

URL where the resource can be found and downloaded from.

Returns:

  • (String)

    Download URL.


12
13
14
# File 'lib/lapis/minecraft/versioning/resource.rb', line 12

def url
  @url
end

Instance Method Details

#==(other) ⇒ true, false

Compares one resource to another.

Parameters:

  • other (Resource)

    Resource to compare against.

Returns:

  • (true)

    The resources are the same.

  • (false)

    The resources are different.


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

def ==(other)
  super(other) &&
      other.url == @url &&
      other.classifier == @classifier
end