Class: EXIFR::TIFF::IFD
- Inherits:
-
Object
show all
- Defined in:
- lib/exifr/tiff.rb
Overview
Instance Attribute Summary (collapse)
Instance Method Summary
(collapse)
Constructor Details
- (IFD) initialize(data, offset = nil, type = :image)
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
|
# File 'lib/exifr/tiff.rb', line 430
def initialize(data, offset = nil, type = :image)
@data, @offset, @type, @fields = data, offset, type, {}
pos = offset || @data.readlong(4)
num = @data.readshort(pos)
pos += 2
num.times do
add_field(Field.new(@data, pos))
pos += 12
end
@offset_next = @data.readlong(pos)
rescue
@offset_next = 0
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(method, *args)
447
448
449
450
|
# File 'lib/exifr/tiff.rb', line 447
def method_missing(method, *args)
super unless args.empty? && TAGS.include?(method.to_s)
to_hash[method]
end
|
Instance Attribute Details
- (Object) fields
Returns the value of attribute fields
428
429
430
|
# File 'lib/exifr/tiff.rb', line 428
def fields
@fields
end
|
- (Object) offset
Returns the value of attribute offset
428
429
430
|
# File 'lib/exifr/tiff.rb', line 428
def offset
@offset
end
|
- (Object) type
Returns the value of attribute type
428
429
430
|
# File 'lib/exifr/tiff.rb', line 428
def type
@type
end
|
Instance Method Details
- (Object) height
453
|
# File 'lib/exifr/tiff.rb', line 453
def height; image_length; end
|
- (Object) inspect
467
468
469
|
# File 'lib/exifr/tiff.rb', line 467
def inspect
to_hash.inspect
end
|
- (Object) next
475
476
477
|
# File 'lib/exifr/tiff.rb', line 475
def next
IFD.new(@data, @offset_next) if next?
end
|
- (Boolean) next?
471
472
473
|
# File 'lib/exifr/tiff.rb', line 471
def next?
@offset_next != 0 && @offset_next < @data.size
end
|
- (Object) to_hash
455
456
457
458
459
460
461
462
463
464
465
|
# File 'lib/exifr/tiff.rb', line 455
def to_hash
@hash ||= @fields.map do |key,value|
if value.nil?
{}
elsif IFD_TAGS.include?(key)
value.to_hash
else
{key => value}
end
end.inject { |m,v| m.merge(v) } || {}
end
|
- (Object) to_yaml_properties
479
480
481
|
# File 'lib/exifr/tiff.rb', line 479
def to_yaml_properties
['@fields']
end
|
- (Object) width
452
|
# File 'lib/exifr/tiff.rb', line 452
def width; image_width; end
|