Sha256: 9b7ae9f5c9901d8a87234e7dad26183a134dc75ebc2d8c82d896ebf8b555f442
Contents?: true
Size: 600 Bytes
Versions: 1
Compression:
Stored size: 600 Bytes
Contents
# frozen_string_literal: true module Remocon module ConditionSorter CONDITION_KEYS = %i[name expression tagColor] def sort_conditions(conditions) conditions .sort_by { |e| e[:name] } .map do |e| arr = e.sort do |(a, _), (b, _)| if !CONDITION_KEYS.include?(a) && !CONDITION_KEYS.include?(b) a <=> b else (CONDITION_KEYS.index(a) || 10000) <=> (CONDITION_KEYS.index(b) || 10000) end end arr.each_with_object({}) { |(k, v), h| h[k] = v }.with_indifferent_access end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
remocon-0.1.0 | lib/remocon/sorter/condition_sorter.rb |