Sha256: 0a6e196b9e826d7f84c2305cdf976843dcc2e9f68d1debf1d14cb34a52808797
Contents?: true
Size: 865 Bytes
Versions: 2
Compression:
Stored size: 865 Bytes
Contents
class Array def that_are(cls) if (cls.kind_of?(Class) or cls.kind_of?(Module)) return self.clone.delete_if { |i| i.kind_of?(cls) == false } else if self.include?(cls) return [cls] end return Array.new end end def that_are_not(cls) if (cls.kind_of?(Class) or cls.kind_of?(Module)) return self.clone.delete_if { |i| i.kind_of?(cls) == true } else return self.clone - [cls] end end def random return self[rand(self.length)] end def shuffle self.sort { |a, b| rand(3) <=> rand(3) } end def shuffle! self.sort! { |a, b| rand(3) <=> rand(3) } end def join_and(sep = ', ', andSep = ' and ', serial = true) if self.length < 3 self.join(andSep) else start = self - [self.last] start.join(sep) + "#{serial ? sep.strip : ''}#{andSep}#{self.last}" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gamefic-0.0.2 | lib/gamefic/core_ext/array.rb |
gamefic-0.0.1 | lib/gamefic/core_ext/array.rb |