Class: EXIFR::TIFF::Data
- Inherits:
-
Object
- Object
- EXIFR::TIFF::Data
- Defined in:
- lib/exifr/tiff.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#double ⇒ Object
readonly
Returns the value of attribute double.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#float ⇒ Object
readonly
Returns the value of attribute float.
-
#long ⇒ Object
readonly
Returns the value of attribute long.
-
#short ⇒ Object
readonly
Returns the value of attribute short.
Class Method Summary collapse
Instance Method Summary collapse
- #[](pos) ⇒ Object
-
#initialize(file) ⇒ Data
constructor
A new instance of Data.
- #readlong(pos) ⇒ Object
- #readshort(pos) ⇒ Object
- #size ⇒ Object
Constructor Details
permalink #initialize(file) ⇒ Data
Returns a new instance of Data.
648 649 650 651 652 653 654 655 656 657 658 659 |
# File 'lib/exifr/tiff.rb', line 648 def initialize(file) @io = file.respond_to?(:read) ? file : (@file = File.open(file, 'rb')) @buffer = '' @pos = 0 case self[0..1] when 'II'; @short, @long, @float, @double = 'v', 'V', 'e', 'E' when 'MM'; @short, @long, @float, @double = 'n', 'N', 'g', 'G' else raise MalformedTIFF, "no byte order information found" end end |
Instance Attribute Details
permalink #double ⇒ Object (readonly)
Returns the value of attribute double.
646 647 648 |
# File 'lib/exifr/tiff.rb', line 646 def double @double end |
permalink #file ⇒ Object (readonly)
Returns the value of attribute file.
646 647 648 |
# File 'lib/exifr/tiff.rb', line 646 def file @file end |
permalink #float ⇒ Object (readonly)
Returns the value of attribute float.
646 647 648 |
# File 'lib/exifr/tiff.rb', line 646 def float @float end |
permalink #long ⇒ Object (readonly)
Returns the value of attribute long.
646 647 648 |
# File 'lib/exifr/tiff.rb', line 646 def long @long end |
permalink #short ⇒ Object (readonly)
Returns the value of attribute short.
646 647 648 |
# File 'lib/exifr/tiff.rb', line 646 def short @short end |
Class Method Details
permalink .open(file, &block) ⇒ Object
[View source]
661 662 663 664 665 666 |
# File 'lib/exifr/tiff.rb', line 661 def self.open(file, &block) data = new(file) yield data ensure data && data.file && data.file.close end |
Instance Method Details
permalink #[](pos) ⇒ Object
[View source]
668 669 670 671 672 673 674 675 676 677 678 |
# File 'lib/exifr/tiff.rb', line 668 def [](pos) unless pos.respond_to?(:begin) && pos.respond_to?(:end) pos = pos..pos end if pos.begin < @pos || pos.end >= @pos + @buffer.size read_for(pos) end @buffer && @buffer[(pos.begin - @pos)..(pos.end - @pos)] end |
permalink #readlong(pos) ⇒ Object
[View source]
684 685 686 |
# File 'lib/exifr/tiff.rb', line 684 def readlong(pos) self[pos..(pos + 3)].unpack(@long)[0] end |
permalink #readshort(pos) ⇒ Object
[View source]
680 681 682 |
# File 'lib/exifr/tiff.rb', line 680 def readshort(pos) self[pos..(pos + 1)].unpack(@short)[0] end |
permalink #size ⇒ Object
[View source]
688 689 690 691 |
# File 'lib/exifr/tiff.rb', line 688 def size @io.seek(0, IO::SEEK_END) @io.pos end |