Class: Eye::Utils::AliveArray

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/eye/utils/alive_array.rb

Instance Method Summary collapse

Constructor Details

#initialize(arr = []) ⇒ AliveArray

Returns a new instance of AliveArray.



7
8
9
# File 'lib/eye/utils/alive_array.rb', line 7

def initialize(arr = [])
  @arr = arr
end

Instance Method Details

#each(&block) ⇒ Object



11
12
13
# File 'lib/eye/utils/alive_array.rb', line 11

def each(&block)
  @arr.each{|elem| elem && elem.alive? && block[elem] }
end

#full_sizeObject



19
20
21
# File 'lib/eye/utils/alive_array.rb', line 19

def full_size
  @arr.size
end

#pureObject



23
24
25
# File 'lib/eye/utils/alive_array.rb', line 23

def pure
  @arr
end

#sort_by(&block) ⇒ Object



27
28
29
# File 'lib/eye/utils/alive_array.rb', line 27

def sort_by(&block)
  self.class.new super
end

#to_aObject



15
16
17
# File 'lib/eye/utils/alive_array.rb', line 15

def to_a
  map{|x| x }
end