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.



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.



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.



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.



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