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
ttfunk-1.2.2 lib/ttfunk/table.rb
ttfunk-1.2.1 lib/ttfunk/table.rb
ttfunk-1.2.0 lib/ttfunk/table.rb
ttfunk-1.1.1 lib/ttfunk/table.rb
ttfunk-1.1.0 lib/ttfunk/table.rb
ttfunk-1.0.3 lib/ttfunk/table.rb
ttfunk-1.0.2 lib/ttfunk/table.rb
ttfunk-1.0.1 lib/ttfunk/table.rb
davebenvenuti-prawn-0.11.1.pre vendor/ttfunk/lib/ttfunk/table.rb
piglop-prawn-0.10.2.3 vendor/ttfunk/lib/ttfunk/table.rb
piglop-prawn-0.10.2.2 vendor/ttfunk/lib/ttfunk/table.rb
piglop-prawn-0.10.2.1 vendor/ttfunk/lib/ttfunk/table.rb
glyph_imager-0.1.1 vendor/ttfunk/lib/ttfunk/table.rb
prawn-0.11.1.pre vendor/ttfunk/lib/ttfunk/table.rb
goodwill-prawn-edge-0.10.0 vendor/ttfunk/lib/ttfunk/table.rb
alphasights-prawn-0.10.4 vendor/ttfunk/lib/ttfunk/table.rb
alphasights-prawn-0.10.3 vendor/ttfunk/lib/ttfunk/table.rb
alphasights-prawn-0.10.2 vendor/ttfunk/lib/ttfunk/table.rb
alphasights-prawn-0.10.1 vendor/ttfunk/lib/ttfunk/table.rb
glyph_imager-0.1.0 vendor/ttfunk/lib/ttfunk/table.rb