Sha256: 1c6ea17842729db21c03d2525d6bdcc9a2de43094554e475168f9dcbe0c3488a

Contents?: true

Size: 757 Bytes

Versions: 7

Compression:

Stored size: 757 Bytes

Contents

module FileData
  # Contains the ability to enumerate through the exif tags in an ifd
  module TagEnumerator
    TAG_RECORD_SIZE = 12

    def tags_enum
      Enumerator.new do |e|
        read_num_tags.times do
          tag_start_pos = stream.pos
          e.yield stream.read_value(2)
          stream.seek(tag_start_pos + TAG_RECORD_SIZE)
        end
      end.lazy
    end

    def read_num_tags
      stream.read_value(2)
    end

    def tags_size(num_tags)
      num_tags * TAG_RECORD_SIZE
    end
  end

  # Represents the tags present in any ifd (ordinal or extra)
  class Ifd
    include TagEnumerator

    attr_accessor :stream

    def initialize(exif_stream)
      @stream = exif_stream
    end

    def tags
      tags_enum
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
file_data-6.0.0 lib/file_data/formats/exif/ifd.rb
file_data-5.2.3 lib/file_data/formats/exif/ifd.rb
file_data-5.2.2 lib/file_data/formats/exif/ifd.rb
file_data-5.2.1 lib/file_data/formats/exif/ifd.rb
file_data-5.2.0 lib/file_data/formats/exif/ifd.rb
file_data-5.0.0 lib/file_data/formats/exif/ifd.rb
file_data-4.0.0 lib/file_data/formats/exif/ifd.rb