Class: ImageVoodoo::Directory

Inherits:
Object
  • Object
show all
Defined in:
lib/image_voodoo/metadata.rb

Overview

All metadata are contained within Directories. An image may have n directories. You have to know a bit about the image to khow what to look at (e.g. a image from a Pentax camera may have a PentaxMakerNote directory.

Instance Method Summary collapse

Constructor Details

#initialize(metadata) ⇒ Directory

Returns a new instance of Directory.



72
73
74
75
# File 'lib/image_voodoo/metadata.rb', line 72

def initialize()
  jclass = self.class.directory_class.java_class
  @directory = .get_first_directory_of_type jclass
end

Instance Method Details

#[](tag_name) ⇒ Object

Return tag value for the tag specified or nil if there is none defined.

Raises:

  • (ArgumentError)


86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/image_voodoo/metadata.rb', line 86

def [](tag_name)
  return nil unless @directory

  (tag_type, tag_method) = self.class::TAGS[tag_name.to_s]

  raise ArgumentError, "Unkown tag_name: #{tag_name}" unless tag_type

  java_tag_type = self.class.directory_class.const_get tag_type

  return nil unless @directory.contains_tag java_tag_type

  @directory.__send__ tag_method, java_tag_type
end

#exists?Boolean

Does the directory you requested exist as metadata for this image.

Returns:

  • (Boolean)


79
80
81
# File 'lib/image_voodoo/metadata.rb', line 79

def exists?
  @directory
end