class TTFunk::OneBasedArray

Attributes

entries[R]

Public Class Methods

new(size = 0) click to toggle source
# File lib/ttfunk/one_based_array.rb, line 7
def initialize(size = 0)
  @entries = Array.new(size)
end

Public Instance Methods

[](idx) click to toggle source
# File lib/ttfunk/one_based_array.rb, line 11
def [](idx)
  if idx.zero?
    raise IndexError,
      "index #{idx} was outside the bounds of the array"
  end

  entries[idx - 1]
end
each(&block) click to toggle source
# File lib/ttfunk/one_based_array.rb, line 28
def each(&block)
  entries.each(&block)
end
size() click to toggle source
# File lib/ttfunk/one_based_array.rb, line 20
def size
  entries.size
end
to_ary() click to toggle source
# File lib/ttfunk/one_based_array.rb, line 24
def to_ary
  entries
end