Class: Eye::Utils::AliveArray
- Inherits:
-
Object
- Object
- Eye::Utils::AliveArray
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/eye/utils/alive_array.rb
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #full_size ⇒ Object
-
#initialize(arr = []) ⇒ AliveArray
constructor
A new instance of AliveArray.
- #pure ⇒ Object
- #sort_by(&block) ⇒ Object
- #to_a ⇒ Object
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_size ⇒ Object
19 20 21 |
# File 'lib/eye/utils/alive_array.rb', line 19 def full_size @arr.size end |
#pure ⇒ Object
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_a ⇒ Object
15 16 17 |
# File 'lib/eye/utils/alive_array.rb', line 15 def to_a map{|x| x } end |