Class: EXIFR::TIFF::IFD
- Inherits:
-
Object
- Object
- EXIFR::TIFF::IFD
- Defined in:
- lib/exifr/tiff.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
-
#raw_fields ⇒ Object
readonly
Returns the value of attribute raw_fields.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #encode_with(coder) ⇒ Object
- #height ⇒ Object
-
#initialize(data, offset = nil, type = :image) ⇒ IFD
constructor
A new instance of IFD.
- #inspect ⇒ Object
- #method_missing(method, *args) ⇒ Object
- #next ⇒ Object
- #next? ⇒ Boolean
- #to_hash ⇒ Object
- #to_yaml_properties ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(data, offset = nil, type = :image) ⇒ IFD
Returns a new instance of IFD.
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 |
# File 'lib/exifr/tiff.rb', line 528 def initialize(data, offset = nil, type = :image) @data, @offset, @type, @raw_fields, @fields = data, offset, type, {}, {} pos = offset || @data.readlong(4) num = @data.readshort(pos) if pos && num pos += 2 num.times do add_field(Field.new(@data, pos)) pos += 12 end @offset_next = @data.readlong(pos) end rescue => ex EXIFR.logger.warn("Badly formed IFD: #{ex}") end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
548 549 550 551 |
# File 'lib/exifr/tiff.rb', line 548 def method_missing(method, *args) super unless args.empty? && TAGS.include?(method) to_hash[method] end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
526 527 528 |
# File 'lib/exifr/tiff.rb', line 526 def fields @fields end |
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
526 527 528 |
# File 'lib/exifr/tiff.rb', line 526 def offset @offset end |
#raw_fields ⇒ Object (readonly)
Returns the value of attribute raw_fields.
526 527 528 |
# File 'lib/exifr/tiff.rb', line 526 def raw_fields @raw_fields end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
526 527 528 |
# File 'lib/exifr/tiff.rb', line 526 def type @type end |
Instance Method Details
#encode_with(coder) ⇒ Object
580 581 582 |
# File 'lib/exifr/tiff.rb', line 580 def encode_with(coder) coder["fields"] = @fields end |
#height ⇒ Object
554 |
# File 'lib/exifr/tiff.rb', line 554 def height; image_length; end |
#inspect ⇒ Object
568 569 570 |
# File 'lib/exifr/tiff.rb', line 568 def inspect to_hash.inspect end |
#next ⇒ Object
576 577 578 |
# File 'lib/exifr/tiff.rb', line 576 def next IFD.new(@data, @offset_next) if next? end |
#next? ⇒ Boolean
572 573 574 |
# File 'lib/exifr/tiff.rb', line 572 def next? @offset_next && @offset_next > 0 && @offset_next < @data.size end |
#to_hash ⇒ Object
556 557 558 559 560 561 562 563 564 565 566 |
# File 'lib/exifr/tiff.rb', line 556 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 |
#to_yaml_properties ⇒ Object
584 585 586 |
# File 'lib/exifr/tiff.rb', line 584 def to_yaml_properties ['@fields'] end |
#width ⇒ Object
553 |
# File 'lib/exifr/tiff.rb', line 553 def width; image_width; end |