From a0f792d8feadf919290b8349dbc0eac143545927 Mon Sep 17 00:00:00 2001 From: _Tradam Date: Mon, 3 Jan 2022 08:26:24 -0500 Subject: Major 4.0 Update (#16) See Changelog --- lib/felflame/order.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 lib/felflame/order.rb (limited to 'lib/felflame/order.rb') diff --git a/lib/felflame/order.rb b/lib/felflame/order.rb new file mode 100644 index 0000000..c11438d --- /dev/null +++ b/lib/felflame/order.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module FelFlame + module Order + # Sets the priority of all items passed into this method + # according to the order they were passed. + # If an array is one of the elements then it will give all + # of those elements in the array the same priority. + # @param sortables [(Systems and Array) or (Scenes and Array)] + # @return [Boolean] +true+. + def self.sort(*sortables) + sortables.each_with_index do |sorted, index| + if sorted.respond_to? :priority + sorted.priority = index + else + sorted.each do |item| + item.priority = index + end + end + end + true + end + end +end -- cgit v1.2.3