module AdventureRL::Extensions::ArrayExtension
ARRAY
Public Instance Methods
include_all?(*vals)
click to toggle source
# File lib/AdventureRL/misc/extensions.rb, line 25 def include_all? *vals return vals.all? do |val| next self.include? val end end
include_any?(*vals)
click to toggle source
# File lib/AdventureRL/misc/extensions.rb, line 30 def include_any? *vals return vals.any? do |val| next self.include? val end end
mean()
click to toggle source
# File lib/AdventureRL/misc/extensions.rb, line 46 def mean return (self.sum.to_f / self.size.to_f) end
sort_by_array(*array)
click to toggle source
# File lib/AdventureRL/misc/extensions.rb, line 35 def sort_by_array *array array.flatten! return self.sort do |one, two| indexes = [ array.index(one), array.index(two) ] next (indexes[0] || Float::INFINITY) <=> (indexes[1] || Float::INFINITY) if (indexes.any?) next one <=> two end end