Class: Lapis::Minecraft::Versioning::Rule

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

Overview

Description of how resources can be chosen.

Direct Known Subclasses

OSRule

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(is_allowed) ⇒ Rule

Creates a basic rule.

Parameters:

  • is_allowed (Boolean)

    Indicates whether the resource should be included.


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

def initialize(is_allowed)
  @is_allowed = !!is_allowed
end

Instance Attribute Details

#allowed?Boolean (readonly)

Indicates whether the resource should be included.

Returns:

  • (Boolean)

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

def allowed?
  @is_allowed
end

Instance Method Details

#==(other) ⇒ true, false

Compares one rule to another.

Parameters:

  • other (Rule)

    Rule to compare against.

Returns:

  • (true)

    The rules are the same.

  • (false)

    The rules are different.


33
34
35
# File 'lib/lapis/minecraft/versioning/rule.rb', line 33

def ==(other)
  other.allowed? == @is_allowed
end

#applies_to?(_properties) ⇒ true, false

Note:

Base rules always apply.

Checks whether the rule applies to a set of properties.

Parameters:

  • _properties (Hash<Symbol => String>)

    Properties to check the rule against.

Returns:

  • (true)

    The rule should be considered when using the resource.

  • (false)

    The rule should not be considered.


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

def applies_to?(_properties)
  true
end