Sha256: 93ebb3ac3614f19b3cd786f991ffb3a374687c83fa379871a2eb707867316bbb

Contents?: true

Size: 724 Bytes

Versions: 5

Compression:

Stored size: 724 Bytes

Contents

# frozen_string_literal: true

require_relative 'reader'

module TTFunk
  class Table
    include Reader

    attr_reader :file
    attr_reader :offset
    attr_reader :length

    def initialize(file)
      @file = file
      @offset = nil
      @length = nil

      info = file.directory_info(tag)

      if info
        @offset = info[:offset]
        @length = info[:length]

        parse_from(@offset) { parse! }
      end
    end

    def exists?
      !@offset.nil?
    end

    def raw
      if exists?
        parse_from(offset) { io.read(length) }
      end
    end

    def tag
      self.class.name.split(/::/).last.downcase
    end

    private

    def parse!
      # do nothing, by default
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ttfunk-1.7.0 lib/ttfunk/table.rb
ttfunk-1.6.2.1 lib/ttfunk/table.rb
ttfunk-1.6.2 lib/ttfunk/table.rb
ttfunk-1.6.1 lib/ttfunk/table.rb
ttfunk-1.6.0 lib/ttfunk/table.rb