Class: Ori::LazyArray

Inherits:
LazyEnumerable show all
Defined in:
lib/ori/lazy.rb

Constant Summary collapse

INIT =
proc { [] }

Instance Method Summary collapse

Methods inherited from LazyEnumerable

#any?, #delete_if, #each, #empty?

Methods inherited from Lazy

#initialized?, #internal

Constructor Details

#initializeLazyArray

Returns a new instance of LazyArray.



48
49
50
# File 'lib/ori/lazy.rb', line 48

def initialize
  super(INIT)
end

Instance Method Details

#[](index) ⇒ Object



52
53
54
# File 'lib/ori/lazy.rb', line 52

def [](index)
  internal[index] if initialized?
end

#[]=(index, value) ⇒ Object



60
61
62
# File 'lib/ori/lazy.rb', line 60

def []=(index, value)
  internal[index] = value
end

#push(value) ⇒ Object Also known as: <<



56
57
58
# File 'lib/ori/lazy.rb', line 56

def push(value)
  internal.push(value)
end

#shiftObject



72
73
74
75
76
# File 'lib/ori/lazy.rb', line 72

def shift
  return unless initialized?

  internal.shift
end

#sizeObject



66
67
68
69
70
# File 'lib/ori/lazy.rb', line 66

def size
  return 0 unless initialized?

  internal.size
end