Class: FixedArray
- Inherits:
-
Object
- Object
- FixedArray
- Includes:
- Enumerable
- Defined in:
- lib/ignition/core/fixed_array.rb
Instance Method Summary collapse
- #<<(value) ⇒ Object
- #each(&blk) ⇒ Object
-
#initialize(num = 50) ⇒ FixedArray
constructor
A new instance of FixedArray.
- #pop ⇒ Object
- #push(value) ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(num = 50) ⇒ FixedArray
Returns a new instance of FixedArray.
4 5 6 7 |
# File 'lib/ignition/core/fixed_array.rb', line 4 def initialize(num = 50) @size = num @queue = Array.new end |
Instance Method Details
#<<(value) ⇒ Object
26 27 28 |
# File 'lib/ignition/core/fixed_array.rb', line 26 def <<(value) push(value) end |
#each(&blk) ⇒ Object
9 10 11 |
# File 'lib/ignition/core/fixed_array.rb', line 9 def each(&blk) @queue.each(&blk) end |
#pop ⇒ Object
13 14 15 |
# File 'lib/ignition/core/fixed_array.rb', line 13 def pop @queue.pop end |
#push(value) ⇒ Object
17 18 19 20 |
# File 'lib/ignition/core/fixed_array.rb', line 17 def push(value) @queue.shift if @queue.size >= @size @queue.push(value) end |
#to_a ⇒ Object
22 23 24 |
# File 'lib/ignition/core/fixed_array.rb', line 22 def to_a @queue.to_a end |