class WarpEngine::Platform
A platform a software is built for (TIC-80, Godot, C64, …): the builtin ones plus those registered with WarpEngine::Configuration#register_platform. Each delegates its details to a service class, WarpEngine::Platforms::<Name>::Service unless the registration names another. Platforms compare equal by name, also to a String.
Constants
- BUILTIN
-
The names of the platforms the engine ships.
- FORMAT
-
The form a registered platform name must have.
- NAMES
-
The builtin platform names; see
Platform.namesfor the full list. - Registration
-
A registered platform: its
name,serviceclass name,built_kinds,CItemplates(adapter name to path) andversion_sourcecommand.
Attributes
The platform name as a String.
Public Class Methods
Source
# File lib/warp_engine/platform.rb, line 25 def all = names.map { |name| new(name) }
Returns a Platform for every name.
Source
# File lib/warp_engine/platform.rb, line 31 def builtin?(name) = BUILTIN.include?(name.to_s)
Returns true when name is a builtin platform.
Source
# File lib/warp_engine/platform.rb, line 28 def exists?(name) = names.include?(name.to_s)
Returns true when name is a builtin or registered platform.
Source
# File lib/warp_engine/platform.rb, line 34 def find(name) return nil unless exists?(name) new(name.to_s) end
Returns the Platform named name, or nil when there is none.
Source
# File lib/warp_engine/platform.rb, line 41 def find!(name) find(name) || raise(ArgumentError, "Unsupported platform: #{name}") end
Returns the Platform named name. Raises ArgumentError when there is none.
Source
# File lib/warp_engine/platform.rb, line 22 def names = BUILTIN + (registrations.keys - BUILTIN)
Returns the builtin names followed by the registered ones.
Source
# File lib/warp_engine/platform.rb, line 56 def initialize(name) @name = name.to_s end
Creates the platform name without checking that it exists.
Source
# File lib/warp_engine/platform.rb, line 46 def registration(name) = registrations[name.to_s]
Returns the Registration of name, or nil.
Source
# File lib/warp_engine/platform.rb, line 49 def registrations = WarpEngine.config.platforms
Returns every Registration, keyed by name.
Public Instance Methods
Source
# File lib/warp_engine/platform.rb, line 90 def ==(other) other.is_a?(Platform) ? name == other.name : name == other.to_s end
Returns true when other is a Platform of the same name or a value whose to_s is the name. Also available as eql?.
Source
# File lib/warp_engine/platform.rb, line 77 def expected_kinds = service_class.expected_kinds
Returns the release asset kinds the platform produces.
Source
# File lib/warp_engine/platform.rb, line 96 def hash = name.hash
Returns the hash of the name, so equal platforms hash alike.
Source
# File lib/warp_engine/platform.rb, line 74 def label = service_class.label
Returns the human-readable platform name from the service class.
Source
# File lib/warp_engine/platform.rb, line 83 def optional_kinds = service_class.optional_kinds & expected_kinds
Returns the expected kinds a release may lack.
Source
# File lib/warp_engine/platform.rb, line 80 def required_kinds = service_class.required_kinds & expected_kinds
Returns the expected kinds a release must have.
Source
# File lib/warp_engine/platform.rb, line 71 def service = service_class.new
Returns a new instance of service_class.
Source
# File lib/warp_engine/platform.rb, line 63 def service_class registered = self.class.registration(name)&.service return registered.to_s.constantize if registered "WarpEngine::Platforms::#{name.camelize}::Service".constantize end
Returns the platform’s service class: the registered one, or else WarpEngine::Platforms::<Name>::Service. Raises NameError when the class does not exist.