Sha256: a7784da89969d94a0696fd0490872f092bc8a8b42ab93327fe4a38f695320d9b
Contents?: true
Size: 755 Bytes
Versions: 4
Compression:
Stored size: 755 Bytes
Contents
# frozen_string_literal: true module TTFunk class Collection include Enumerable def self.open(path) ::File.open(path, 'rb') do |io| yield new(io) end end def initialize(io) tag = io.read(4) raise ArgumentError, 'not a TTC file' unless tag == 'ttcf' _major, _minor = io.read(4).unpack('n*') count = io.read(4).unpack1('N') @offsets = io.read(count * 4).unpack('N*') io.rewind @contents = io.read @cache = [] end def count @offsets.length end def each count.times do |index| yield self[index] end self end def [](index) @cache[index] ||= TTFunk::File.new(@contents, @offsets[index]) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
ttfunk-1.6.2.1 | lib/ttfunk/collection.rb |
ttfunk-1.6.2 | lib/ttfunk/collection.rb |
ttfunk-1.6.1 | lib/ttfunk/collection.rb |
ttfunk-1.6.0 | lib/ttfunk/collection.rb |