Class: Lapis::Minecraft::Versioning::Manifest

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/lapis/minecraft/versioning/manifest.rb

Overview

Contains basic information about all known versions of Minecraft.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(versions, latest_release_id, latest_snapshot_id) ⇒ Manifest

Creates a new manifest with version instances.

Parameters:

  • versions (Array<Basic>)

    List of all versions.

  • latest_release_id (String)

    ID of the version for the latest release.

  • latest_snapshot_id (String)

    ID of the version for the latest snapshot.



21
22
23
24
25
# File 'lib/lapis/minecraft/versioning/manifest.rb', line 21

def initialize(versions, latest_release_id, latest_snapshot_id)
  @versions        = versions.dup.freeze
  @latest_release  = versions.find { |version| version.id == latest_release_id }
  @latest_snapshot = versions.find { |version| version.id == latest_snapshot_id }
end

Instance Attribute Details

#latest_releaseBasic (readonly)

Retrieves information about the latest release.

Returns:



11
12
13
# File 'lib/lapis/minecraft/versioning/manifest.rb', line 11

def latest_release
  @latest_release
end

#latest_snapshotBasic (readonly)

Retrieves information about the latest snapshot.

Returns:



15
16
17
# File 'lib/lapis/minecraft/versioning/manifest.rb', line 15

def latest_snapshot
  @latest_snapshot
end

Instance Method Details

#==(other) ⇒ true, false

Compares one manifest to another.

Parameters:

  • other (Manifest)

    Manifest to compare against.

Returns:

  • (true)

    The manifests are the same.

  • (false)

    The manifests are different.



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

def ==(other)
  other.entries == @versions &&
      other.latest_release == @latest_release &&
      other.latest_snapshot == @latest_snapshot
end

#eachObject



27
28
29
30
31
32
33
# File 'lib/lapis/minecraft/versioning/manifest.rb', line 27

def each
  return enum_for(:each) unless block_given?

  @versions.each do |version|
    yield version
  end
end