class ROCrate::Metadata
A representation of the `ro-crate-metadata.jsonld` file.
Constants
- CONTEXT
- IDENTIFIER
- IDENTIFIER_1_0
- RO_CRATE_BASE
- SPEC
Public Class Methods
new(crate, properties = {})
click to toggle source
Calls superclass method
ROCrate::File::new
# File lib/ro_crate/model/metadata.rb, line 11 def initialize(crate, properties = {}) super(crate, nil, IDENTIFIER, properties) end
Public Instance Methods
context()
click to toggle source
# File lib/ro_crate/model/metadata.rb, line 23 def context @context || CONTEXT end
context=(c)
click to toggle source
# File lib/ro_crate/model/metadata.rb, line 27 def context= c @context = c end
generate()
click to toggle source
Generate the crate's `ro-crate-metadata.jsonld`. @return [String] The rendered JSON-LD as a “prettified” string.
# File lib/ro_crate/model/metadata.rb, line 18 def generate graph = crate.entities.map(&:properties).reject(&:empty?) JSON.pretty_generate('@context' => context, '@graph' => graph) end
Private Instance Methods
default_properties()
click to toggle source
# File lib/ro_crate/model/metadata.rb, line 37 def default_properties { '@id' => IDENTIFIER, '@type' => 'CreativeWork', 'about' => { '@id' => crate.id }, 'conformsTo' => { '@id' => SPEC } } end
source()
click to toggle source
# File lib/ro_crate/model/metadata.rb, line 33 def source Entry.new(StringIO.new(generate)) end