Class: APDM::Saxo::Metadata

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ Metadata

Returns a new instance of Metadata.



18
19
20
21
# File 'lib/apdm/saxo/metadata.rb', line 18

def initialize(data = {})
  data = data.dup
  self. = data.each {|k,v| data[k] = convert(Metadata.sanitize(v))}
end

Instance Attribute Details

#metadataObject

Returns the value of attribute metadata.



16
17
18
# File 'lib/apdm/saxo/metadata.rb', line 16

def 
  @metadata
end

Class Method Details

.sanitize(s) ⇒ Object



7
8
9
# File 'lib/apdm/saxo/metadata.rb', line 7

def sanitize(s)
  s.gsub(/`/, "'").gsub(/´/, '\'').gsub(/"/, '\"').gsub('<3', ':heart:').gsub(/[<>]/, '').squeeze(' ')
end

.to_iso88591(utf8_string) ⇒ Object



11
12
13
# File 'lib/apdm/saxo/metadata.rb', line 11

def to_iso88591(utf8_string)
  utf8_string.encode(Encoding::ISO_8859_1, Encoding::UTF_8, :undef => :replace)
end

Instance Method Details

#to(name, path, options = {}) ⇒ Object



23
24
25
26
27
# File 'lib/apdm/saxo/metadata.rb', line 23

def to(name, path, options = {})
  iptc = IPTC.new(name, path, options)
  iptc.write()
  iptc
end