class TTFunk::Table::Cff::OneBasedIndex

CFF Index with indexing starting at 1.

Attributes

base_index[R]

Underlaying Index. @return [TTFunk::Table::Cff::Index]

Public Class Methods

new(*args) click to toggle source

@param args [Array] all params are passed to the base index. @see Index

# File lib/ttfunk/table/cff/one_based_index.rb, line 25
def initialize(*args)
  @base_index = Index.new(*args)
end

Public Instance Methods

[](idx) click to toggle source

Get item by index.

@param idx [Integer] @return [any] @raise [IndexError] when requested index is 0.

# File lib/ttfunk/table/cff/one_based_index.rb, line 34
def [](idx)
  if idx.zero?
    raise IndexError,
      "index #{idx} was outside the bounds of the index"
  end

  base_index[idx - 1]
end