Class: LumiaServer::Platform
- Inherits:
-
Object
- Object
- LumiaServer::Platform
- Defined in:
- lib/lumia-server/platform.rb,
lib/lumia-server/platform/paper.rb,
lib/lumia-server/platform/custom.rb,
lib/lumia-server/platform/waterfall.rb,
lib/lumia-server/platform/bungeecord.rb
Direct Known Subclasses
Defined Under Namespace
Classes: BungeeCord, Custom, Paper, Waterfall
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
-
#server_yaml ⇒ Object
readonly
Returns the value of attribute server_yaml.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data, server_yaml) ⇒ Platform
constructor
A new instance of Platform.
- #install ⇒ Object
- #install_platform ⇒ Object
- #needs_update ⇒ Object
Constructor Details
#initialize(data, server_yaml) ⇒ Platform
Returns a new instance of Platform.
27 28 29 30 31 32 33 34 |
# File 'lib/lumia-server/platform.rb', line 27 def initialize(data, server_yaml) @data = data @server_yaml = server_yaml @version = data['version'] @provider = data.key?('provider') ? Provider.new(@data['provider']) : nil @id = provider.nil? ? version : provider.id end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/lumia-server/platform.rb', line 6 def data @data end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/lumia-server/platform.rb', line 12 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/lumia-server/platform.rb', line 9 def name @name end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
11 12 13 |
# File 'lib/lumia-server/platform.rb', line 11 def provider @provider end |
#server_yaml ⇒ Object (readonly)
Returns the value of attribute server_yaml.
7 8 9 |
# File 'lib/lumia-server/platform.rb', line 7 def server_yaml @server_yaml end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
10 11 12 |
# File 'lib/lumia-server/platform.rb', line 10 def version @version end |
Class Method Details
.new(data, server_yaml) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/lumia-server/platform.rb', line 19 def self.new(data, server_yaml) return super if self < Platform const = data['id'].to_s.downcase raise format('Unknown platform %p', data['id']) unless (const = constants.detect { |c| c.to_s.downcase == const }) platform = const_get(const).new(data, server_yaml) platform end |
Instance Method Details
#install ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/lumia-server/platform.rb', line 36 def install if needs_update puts "#{name}: updating.." install_platform else puts "#{name}: up-to-date" end end |
#install_platform ⇒ Object
49 50 |
# File 'lib/lumia-server/platform.rb', line 49 def install_platform; end |
#needs_update ⇒ Object
45 46 47 |
# File 'lib/lumia-server/platform.rb', line 45 def needs_update server_yaml.nil? || server_yaml[name] != id end |