lib/ttfunk/table.rb in ttfunk-1.7.0 vs lib/ttfunk/table.rb in ttfunk-1.8.0

- old
+ new

@@ -1,17 +1,27 @@ # frozen_string_literal: true require_relative 'reader' module TTFunk + # SFNT table class Table include Reader + # File this table is in. + # @return [TTFunk::File] attr_reader :file + + # This table's offset from the file beginning. + # @return [Integer] attr_reader :offset + + # This table's length in byes. + # @return [Integer, nil] attr_reader :length + # @param file [TTFunk::File] def initialize(file) @file = file @offset = nil @length = nil @@ -23,21 +33,30 @@ parse_from(@offset) { parse! } end end + # Does this table exist in the file? + # + # @return [Boolean] def exists? !@offset.nil? end + # Raw bytes of this table in the file. + # + # @return [String, nil] def raw if exists? parse_from(offset) { io.read(length) } end end + # Table tag. + # + # @return [String] def tag - self.class.name.split(/::/).last.downcase + self.class.name.split('::').last.downcase end private def parse!