Class: Lapis::Minecraft::Versioning::OSRule

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

Overview

Description of how resources can be chosen for operating systems.

Instance Attribute Summary collapse

Attributes inherited from Rule

#allowed?

Instance Method Summary collapse

Constructor Details

#initialize(is_allowed, os_type, os_version = nil) ⇒ OSRule

Creates an OS rule.

Parameters:

  • is_allowed (Boolean)

    Indicates whether the resource should be included.

  • os_type (Symbol)

    Type of OS this rule applies to. Can be one of: :windows, :linux, or :osx.

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

    OS version regex. Can be nil to apply to all versions of the OS.



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

def initialize(is_allowed, os_type, os_version = nil)
  super(is_allowed)
  @os_type = os_type
  @os_version = os_version ? Regexp.new(os_version) : // # Use empty regex if no version specified.
end

Instance Attribute Details

#os_typeSymbol (readonly)

Type of operating system this rule applies to.

Returns:

  • (Symbol)

    Can be one of: :windows, :linux, or :osx.



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

def os_type
  @os_type
end

#os_versionRegexp (readonly)

Operating system version regex. This rule should apply if the OS version matches this regex.

Returns:

  • (Regexp)


17
18
19
# File 'lib/lapis/minecraft/versioning/os_rule.rb', line 17

def os_version
  @os_version
end

Instance Method Details

#==(other) ⇒ true, false

Compares one rule to another.

Parameters:

  • other (OSRule)

    Rule to compare against.

Returns:

  • (true)

    The rules are the same.

  • (false)

    The rules are different.



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

def ==(other)
  super(other) &&
      other.os_type == @os_type &&
      other.os_version == @os_version
end