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:



25
26
27
# File 'lib/ttfunk/table/cff/one_based_index.rb', line 25

def initialize(*args)
  @base_index = Index.new(*args)
end

Instance Attribute Details

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

Underlaying Index.



21
22
23
# File 'lib/ttfunk/table/cff/one_based_index.rb', line 21

def base_index
  @base_index
end

Instance Method Details

#[](idx) ⇒ any

Get item by index.

Parameters:

  • idx (Integer)

Returns:

  • (any)

Raises:

  • (IndexError)

    when requested index is 0.



34
35
36
37
38
39
40
41
# 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