Class: Deplate::Metadata
- Inherits:
-
Object
- Object
- Deplate::Metadata
- Defined in:
- lib/deplate/metadata.rb
Overview
Metadata:
Instance Attribute Summary collapse
-
#metadata ⇒ Object
Returns the value of attribute metadata.
Instance Method Summary collapse
- #destination(destination = nil) ⇒ Object
- #format_metadata(metadata = @metadata) ⇒ Object
-
#initialize(deplate, output = nil) ⇒ Metadata
constructor
A new instance of Metadata.
- #merge_metadata(metadata) ⇒ Object
- #metadata_available? ⇒ Boolean
- #metadata_destination(master_file = nil) ⇒ Object
- #push_metadata(data) ⇒ Object
Constructor Details
#initialize(deplate, output = nil) ⇒ Metadata
Returns a new instance of Metadata.
21 22 23 24 25 |
# File 'lib/deplate/metadata.rb', line 21 def initialize(deplate, output=nil) @deplate = deplate @output = output @metadata = {} end |
Instance Attribute Details
#metadata ⇒ Object
Returns the value of attribute metadata.
19 20 21 |
# File 'lib/deplate/metadata.rb', line 19 def @metadata end |
Instance Method Details
#destination(destination = nil) ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/deplate/metadata.rb', line 47 def destination(destination=nil) if destination destination elsif @output @output.destination else # <+TBD+> '' end end |
#format_metadata(metadata = @metadata) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/deplate/metadata.rb', line 63 def (=@metadata) unless .nil? or .empty? for type, value in if value for e in value e['file'] = destination.dup end end end ['creator'] = 'deplate' ['creator_version'] = Deplate::Core.version @deplate.() end end |
#merge_metadata(metadata) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/deplate/metadata.rb', line 27 def () if @deplate.. for e in (e) end end end |
#metadata_available? ⇒ Boolean
43 44 45 |
# File 'lib/deplate/metadata.rb', line 43 def !@metadata.empty? end |
#metadata_destination(master_file = nil) ⇒ Object
58 59 60 61 |
# File 'lib/deplate/metadata.rb', line 58 def (master_file=nil) dest = destination(master_file) Deplate::Core.canonic_file_name(dest, @deplate..) end |
#push_metadata(data) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/deplate/metadata.rb', line 35 def (data) if @deplate.. type = data["type"] @metadata[type] ||= [] @metadata[type] << data end end |