Class: ExifTagger::Tag::Tag
- Inherits:
-
Object
- Object
- ExifTagger::Tag::Tag
- Includes:
- Comparable
- Defined in:
- lib/phtools/exif_tagger/tags/_tag.rb
Overview
Parent class for all tags
Direct Known Subclasses
City, CodedCharacterSet, Collections, Copyright, Country, CountryCode, Creator, GpsCreated, ImageUniqueId, Keywords, Location, State, TagDate, WorldRegion
Constant Summary collapse
- EXIFTOOL_TAGS =
[]
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#force_write ⇒ Object
Returns the value of attribute force_write.
-
#info ⇒ Object
Returns the value of attribute info.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
-
#value_invalid ⇒ Object
readonly
Returns the value of attribute value_invalid.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
-
#write_script_lines ⇒ Object
readonly
Returns the value of attribute write_script_lines.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #check_for_warnings(original_values: {}) ⇒ Object
-
#initialize(value_norm = '') ⇒ Tag
constructor
A new instance of Tag.
- #tag_id ⇒ Object
- #tag_name ⇒ Object
- #to_s ⇒ Object
- #to_write_script ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(value_norm = '') ⇒ Tag
Returns a new instance of Tag.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/phtools/exif_tagger/tags/_tag.rb', line 17 def initialize(value_norm = '') @value = value_norm @errors = [] @value_invalid = [] @warnings = [] @write_script_lines = [] @info = '' @force_write = false validate @value.freeze @errors.freeze @value_invalid.freeze @warnings.freeze end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
14 15 16 |
# File 'lib/phtools/exif_tagger/tags/_tag.rb', line 14 def errors @errors end |
#force_write ⇒ Object
Returns the value of attribute force_write.
15 16 17 |
# File 'lib/phtools/exif_tagger/tags/_tag.rb', line 15 def force_write @force_write end |
#info ⇒ Object
Returns the value of attribute info.
15 16 17 |
# File 'lib/phtools/exif_tagger/tags/_tag.rb', line 15 def info @info end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
14 15 16 |
# File 'lib/phtools/exif_tagger/tags/_tag.rb', line 14 def value @value end |
#value_invalid ⇒ Object (readonly)
Returns the value of attribute value_invalid.
14 15 16 |
# File 'lib/phtools/exif_tagger/tags/_tag.rb', line 14 def value_invalid @value_invalid end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
14 15 16 |
# File 'lib/phtools/exif_tagger/tags/_tag.rb', line 14 def warnings @warnings end |
#write_script_lines ⇒ Object (readonly)
Returns the value of attribute write_script_lines.
14 15 16 |
# File 'lib/phtools/exif_tagger/tags/_tag.rb', line 14 def write_script_lines @write_script_lines end |
Instance Method Details
#<=>(other) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/phtools/exif_tagger/tags/_tag.rb', line 40 def <=>(other) if other.respond_to? :tag_id tag_id <=> other.tag_id else tag_id <=> other.to_s.to_sym end end |
#check_for_warnings(original_values: {}) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/phtools/exif_tagger/tags/_tag.rb', line 56 def check_for_warnings(original_values: {}) @warnings = [] self.class::EXIFTOOL_TAGS.each do |tag| v = original_values[tag] unless v.nil? case when v.kind_of?(String) @warnings << "#{tag_name} has original value: #{tag}='#{v}'" unless v.empty? when v.kind_of?(Array) @warnings << "#{tag_name} has original value: #{tag}=#{v}" unless v.join.empty? else @warnings << "#{tag_name} has original value: #{tag}=#{v}" end end end @warnings.freeze end |
#tag_id ⇒ Object
32 33 34 |
# File 'lib/phtools/exif_tagger/tags/_tag.rb', line 32 def tag_id self.class.to_s.demodulize.underscore.to_sym end |
#tag_name ⇒ Object
36 37 38 |
# File 'lib/phtools/exif_tagger/tags/_tag.rb', line 36 def tag_name self.class.to_s.demodulize end |
#to_s ⇒ Object
48 49 50 |
# File 'lib/phtools/exif_tagger/tags/_tag.rb', line 48 def to_s "#{tag_id} = #{@value}" end |
#to_write_script ⇒ Object
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/phtools/exif_tagger/tags/_tag.rb', line 74 def to_write_script str = '' generate_write_script_lines unless @write_script_lines.empty? str << print_info str << print_warnings str << print_lines end str end |
#valid? ⇒ Boolean
52 53 54 |
# File 'lib/phtools/exif_tagger/tags/_tag.rb', line 52 def valid? @errors.empty? end |