Sha256: 1708d191653d25fd297a4a453dda97dade76d887e2345a319a464051066ba7fb

Contents?: true

Size: 653 Bytes

Versions: 4

Compression:

Stored size: 653 Bytes

Contents

require_relative 'reader'

module TTFunk
  class Table
    include Reader

    attr_reader :file
    attr_reader :offset
    attr_reader :length

    def initialize(file)
      @file = file

      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

4 entries across 3 versions & 2 rubygems

Version Path
embulk-input-druginfo_interview_form-0.1.0 vendor/bundle/ruby/2.4.0/gems/ttfunk-1.5.1/lib/ttfunk/table.rb
embulk-input-druginfo_interview_form-0.1.0 vendor/bundle/ruby/2.5.0/gems/ttfunk-1.5.1/lib/ttfunk/table.rb
ttfunk-1.5.1 lib/ttfunk/table.rb
ttfunk-1.5.0 lib/ttfunk/table.rb