Class: Tootsie::ImageMetadataExtractor
- Inherits:
-
Object
- Object
- Tootsie::ImageMetadataExtractor
- Defined in:
- lib/tootsie/image_metadata_extractor.rb
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Instance Method Summary collapse
- #extract_from_file(file_name) ⇒ Object
-
#initialize(options = {}) ⇒ ImageMetadataExtractor
constructor
A new instance of ImageMetadataExtractor.
Constructor Details
#initialize(options = {}) ⇒ ImageMetadataExtractor
Returns a new instance of ImageMetadataExtractor.
7 8 9 10 |
# File 'lib/tootsie/image_metadata_extractor.rb', line 7 def initialize( = {}) @logger = [:logger] @metadata = {} end |
Instance Attribute Details
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
28 29 30 |
# File 'lib/tootsie/image_metadata_extractor.rb', line 28 def @metadata end |
Instance Method Details
#extract_from_file(file_name) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/tootsie/image_metadata_extractor.rb', line 12 def extract_from_file(file_name) run_exiv2("-pt :file", :file => file_name) do |line| parse_exiv2_line(line) end run_exiv2("-pi :file", :file => file_name) do |line| parse_exiv2_line(line) end run_exiv2("-px :file", :file => file_name) do |line| parse_exiv2_line(line) end @metadata = Hash[*@metadata.entries.map { |key, values| [key, values.length > 1 ? values : values.first] }.flatten(1)] @metadata end |