Class: Xmpleton::Reader
- Inherits:
-
Object
- Object
- Xmpleton::Reader
- Defined in:
- lib/xmpleton.rb
Instance Method Summary collapse
-
#initialize(image_file) ⇒ Reader
constructor
A new instance of Reader.
- #tags ⇒ Object
Constructor Details
#initialize(image_file) ⇒ Reader
Returns a new instance of Reader.
5 6 7 8 9 10 11 12 13 |
# File 'lib/xmpleton.rb', line 5 def initialize(image_file) image_file = image_file.clone image_file.rewind binary_data = image_file.read xmp_start = binary_data.index '<x:xmpmeta' xmp_end = binary_data.index('</x:xmpmeta>') @xmp_data = binary_data[xmp_start..xmp_end + 11] if xmp_start and xmp_end @xml = Nokogiri::XML.parse(@xmp_data) end |
Instance Method Details
#tags ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/xmpleton.rb', line 15 def = [] subject = @xml.css("dc|subject", 'dc' => 'http://purl.org/dc/elements/1.1/') if subject && !subject.empty? items = subject.css("rdf|li", 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#') = items.map { |i| i.text } end end |