Class: TTFunk::Table::Cff::OneBasedIndex

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/ttfunk/table/cff/one_based_index.rb

Overview

CFF Index with indexing starting at 1.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ OneBasedIndex

Returns a new instance of OneBasedIndex.

Parameters:

  • args (Array)

    all params are passed to the base index.

See Also:

Source Code
lib/ttfunk/table/cff/one_based_index.rb, line 25
25
def initialize(*args)
26
  @base_index = Index.new(*args)
27
end

Instance Attribute Details

#base_indexTTFunk::Table::Cff::Index (readonly)

Underlaying Index.

Source Code
lib/ttfunk/table/cff/one_based_index.rb, line 21
21
def base_index
22
  @base_index
23
end

Instance Method Details

#[](idx) ⇒ any

Get item by index.

Parameters:

  • idx (Integer)

Returns:

  • (any)

Raises:

  • (IndexError)

    when requested index is 0.

Source Code
lib/ttfunk/table/cff/one_based_index.rb, line 34
34
def [](idx)
35
  if idx.zero?
36
    raise IndexError,
37
      "index #{idx} was outside the bounds of the index"
38
  end
39
40
  base_index[idx - 1]
41
end