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.


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.


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.


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.


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

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

#[](id) ⇒ Basic?

Retrieves version information given a specific ID.


42
43
44
# File 'lib/lapis/minecraft/versioning/manifest.rb', line 42

def [](id)
  @versions.find { |version| version.id == id }
end

#each {|version| ... } ⇒ Enumerator<Basic>

Iterates over all versions.

Yield Parameters:

  • version (Basic)

    Next version in the list.


30
31
32
33
34
35
36
# File 'lib/lapis/minecraft/versioning/manifest.rb', line 30

def each
  return enum_for(:each) unless block_given?

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