Sha256: ab4e75f36202303ccee7d09233802e84d0ac0801465a1a64c9c587d1533ef8ee

Contents?: true

Size: 680 Bytes

Versions: 34

Compression:

Stored size: 680 Bytes

Contents

require 'ttfunk/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) }
      else
        nil
      end
    end

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

    private

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

Version data entries

34 entries across 34 versions & 10 rubygems

Version Path
prawn-core-0.8.4 vendor/ttfunk/lib/ttfunk/table.rb
prawn-graph-0.0.2 vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table.rb
prawn-graph-0.0.1 vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table.rb
prawn-core-0.7.2 vendor/ttfunk/lib/ttfunk/table.rb
prawn-core-0.7.1 vendor/ttfunk/lib/ttfunk/table.rb
prawn-layout-0.3.2 vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table.rb
prawn-core-0.6.3 vendor/ttfunk/lib/ttfunk/table.rb
prawn-core-0.6.2 vendor/ttfunk/lib/ttfunk/table.rb
prawn-layout-0.3.1 vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table.rb
prawn-core-0.6.1 vendor/ttfunk/lib/ttfunk/table.rb
prawn-core-0.5.1 vendor/ttfunk/lib/ttfunk/table.rb
prawn-core-0.5.0.1 vendor/ttfunk/lib/ttfunk/table.rb
prawn-0.4.0 vendor/ttfunk/lib/ttfunk/table.rb
prawn-0.4.1 vendor/ttfunk/lib/ttfunk/table.rb