Class: LumiaServer::Platform

Inherits:
Object
  • Object
show all
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

BungeeCord, Custom, Paper, Waterfall

Defined Under Namespace

Classes: BungeeCord, Custom, Paper, Waterfall

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#dataObject (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/lumia-server/platform.rb', line 6

def data
  @data
end

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/lumia-server/platform.rb', line 12

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/lumia-server/platform.rb', line 9

def name
  @name
end

#providerObject (readonly)

Returns the value of attribute provider.



11
12
13
# File 'lib/lumia-server/platform.rb', line 11

def provider
  @provider
end

#server_yamlObject (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

#versionObject (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

#installObject



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_platformObject



49
50
# File 'lib/lumia-server/platform.rb', line 49

def install_platform;
end

#needs_updateObject



45
46
47
# File 'lib/lumia-server/platform.rb', line 45

def needs_update
  server_yaml.nil? || server_yaml[name] != id
end