Class: Cul::Image::Properties::Exif::IFD_Tag
- Inherits:
-
Object
- Object
- Cul::Image::Properties::Exif::IFD_Tag
- Defined in:
- lib/cul_image_props/image/properties/exif/types.rb
Overview
for ease of dealing with tags
Instance Attribute Summary collapse
-
#field_length ⇒ Object
Returns the value of attribute field_length.
-
#field_offset ⇒ Object
Returns the value of attribute field_offset.
-
#field_type ⇒ Object
Returns the value of attribute field_type.
-
#tag ⇒ Object
Returns the value of attribute tag.
-
#values ⇒ Object
Returns the value of attribute values.
Instance Method Summary collapse
-
#initialize(tag_id, field_type, tag_entry, values, field_offset, count) ⇒ IFD_Tag
constructor
A new instance of IFD_Tag.
- #inspect ⇒ Object
- #printable ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(tag_id, field_type, tag_entry, values, field_offset, count) ⇒ IFD_Tag
Returns a new instance of IFD_Tag.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/cul_image_props/image/properties/exif/types.rb', line 96 def initialize( tag_id, field_type, tag_entry, values, field_offset, count) # tag ID number @tag = tag_id # field type as index into FIELD_TYPES @field_type = field_type # the TagEntry looked up for this tag_id @tag_entry = tag_entry # offset of start of field in bytes from beginning of IFD @field_offset = field_offset # length of data field in bytes @count = count typelen = FIELD_TYPES[@field_type].length @field_length = count * typelen # either a string or array of data items @values = values end |
Instance Attribute Details
#field_length ⇒ Object
Returns the value of attribute field_length.
95 96 97 |
# File 'lib/cul_image_props/image/properties/exif/types.rb', line 95 def field_length @field_length end |
#field_offset ⇒ Object
Returns the value of attribute field_offset.
95 96 97 |
# File 'lib/cul_image_props/image/properties/exif/types.rb', line 95 def field_offset @field_offset end |
#field_type ⇒ Object
Returns the value of attribute field_type.
95 96 97 |
# File 'lib/cul_image_props/image/properties/exif/types.rb', line 95 def field_type @field_type end |
#tag ⇒ Object
Returns the value of attribute tag.
95 96 97 |
# File 'lib/cul_image_props/image/properties/exif/types.rb', line 95 def tag @tag end |
#values ⇒ Object
Returns the value of attribute values.
95 96 97 |
# File 'lib/cul_image_props/image/properties/exif/types.rb', line 95 def values @values end |
Instance Method Details
#inspect ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/cul_image_props/image/properties/exif/types.rb', line 131 def inspect begin s= format("(0x%04X) %s=%s @ %d", @tag, FIELD_TYPES[@field_type].name, printable, @field_offset) rescue s= format("(%s) %s=%s @ %s", @tag.to_s, FIELD_TYPES[@field_type].name, printable, @field_offset.to_s) end return s end |
#printable ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/cul_image_props/image/properties/exif/types.rb', line 113 def printable @printable ||= begin if @tag_entry.translates? @tag_entry.translate @values elsif @count == 1 and @field_type != 2 @values[0].to_s elsif @count > 50 and @values.length > 20 (field_type == 2) ? (@values[0...20] + '...') : ("[" + @values[0...20].join(',') + ", ... ]") else @values.inspect end end end |
#to_s ⇒ Object
127 128 129 |
# File 'lib/cul_image_props/image/properties/exif/types.rb', line 127 def to_s printable end |