Sha256: 374634bb2ec5833a22c873e21ae45f3442e7a83f658cd2287a604ed1939e5d37

Contents?: true

Size: 998 Bytes

Versions: 9

Compression:

Stored size: 998 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true
# encoding: UTF-8
# (c) ANB Andrew Bizyaev

require_relative '_tag'

module ExifTagger
  module Tag
    class TagHashOfStrings < Tag
      private

      def validate_hash_items
      end

      def validate_type
        if @value.is_a?(Hash)
          @value.each_value do |val|
            validate_string_size(val)
          end
          unknown_keys = @value.keys - self.class::VALID_KEYS
          unknown_keys.each do |k|
            @errors << %(#{tag_name}: KEY '#{k}' is unknown)
          end
          missed_keys = self.class::VALID_KEYS - @value.keys
          missed_keys.each do |k|
            @errors << %(#{tag_name}: KEY '#{k}' is missed)
          end
          validate_hash_items if @errors.empty?
        else
          @errors << %(#{tag_name}: '#{@value}' is a wrong type \(#{@value.class}\))
        end
        return if @errors.empty?
        @value_invalid << @value
        @value = EMPTY
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
phtools-0.18.0 lib/phtools/exif_tagger/tags/_tag_hash_of_strings.rb
phtools-0.17.0 lib/phtools/exif_tagger/tags/_tag_hash_of_strings.rb
phtools-0.16.1 lib/phtools/exif_tagger/tags/_tag_hash_of_strings.rb
phtools-0.16.0 lib/phtools/exif_tagger/tags/_tag_hash_of_strings.rb
phtools-0.15.1 lib/phtools/exif_tagger/tags/_tag_hash_of_strings.rb
phtools-0.15.0 lib/phtools/exif_tagger/tags/_tag_hash_of_strings.rb
phtools-0.14.0 lib/phtools/exif_tagger/tags/_tag_hash_of_strings.rb
phtools-0.11.2 lib/phtools/exif_tagger/tags/_tag_hash_of_strings.rb
phtools-0.11.1 lib/phtools/exif_tagger/tags/_tag_hash_of_strings.rb