Class: Dimensions::TiffScanner

Inherits:
Scanner
  • Object
show all
Includes:
TiffScanning
Defined in:
lib/dimensions/tiff_scanner.rb

Constant Summary collapse

WIDTH_TAG =
0x100
HEIGHT_TAG =
0x101

Instance Attribute Summary collapse

Attributes inherited from Scanner

#pos

Instance Method Summary collapse

Methods included from TiffScanning

#read_integer_value, #scan_and_skip_to_offset, #scan_endianness, #scan_header, #scan_ifd, #scan_tag_mark

Methods inherited from Scanner

#advance, #big!, #little!, #raise_scan_error, #read, #read_char, #read_data, #read_long, #read_short, #skip_to

Constructor Details

#initialize(data) ⇒ TiffScanner

Returns a new instance of TiffScanner.



13
14
15
16
17
# File 'lib/dimensions/tiff_scanner.rb', line 13

def initialize(data)
  @width  = nil
  @height = nil
  super
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



11
12
13
# File 'lib/dimensions/tiff_scanner.rb', line 11

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width.



11
12
13
# File 'lib/dimensions/tiff_scanner.rb', line 11

def width
  @width
end

Instance Method Details

#scanObject



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dimensions/tiff_scanner.rb', line 19

def scan
  scan_header

  scan_ifd do |tag|
    if tag == WIDTH_TAG
      @width = read_integer_value
    elsif tag == HEIGHT_TAG
      @height = read_integer_value
    end
  end

  @width && @height
end