Sha256: c55c8b0016a670c9bb787604b0e2aae453c24661715638c1fcb6e545ee3cf048
Contents?: true
Size: 883 Bytes
Versions: 2
Compression:
Stored size: 883 Bytes
Contents
class Eye::Utils::AliveArray extend Forwardable include Enumerable def_delegators :@arr, :[], :<<, :clear, :delete, :size, :empty?, :push, :flatten, :present?, :uniq! def initialize(arr = []) @arr = arr end def each(&block) @arr.each{|elem| elem && elem.alive? && block[elem] } end def to_a map{|x| x } end def full_size @arr.size end def pure @arr end def sort_by(&block) self.class.new super end def +(other) if other.is_a?(Eye::Utils::AliveArray) @arr += other.pure elsif other.is_a?(Array) @arr += other else raise "Unexpected + #{other}" end self end def ==(other) if other.is_a?(Eye::Utils::AliveArray) @arr == other.pure elsif other.is_a?(Array) @arr == other else raise "Unexpected == #{other}" end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
reel-eye-0.3.2 | lib/eye/utils/alive_array.rb |
eye-0.3.2 | lib/eye/utils/alive_array.rb |