class ROBundle::Annotation
A class to represent an Annotation in a Research Object.
Public Class Methods
new(target, content = nil)
click to toggle source
Create a new Annotation with the specified
“about” identifier. A new annotation ID is generated and set for the new
annotation. The content
parameter can be optionally used to
set the file or URI that holds the body of the annotation.
An annotation id is a UUID prefixed with “urn:uuid” as per RFC4122.
# File lib/ro-bundle/ro/annotation.rb, line 26 def initialize(object, content = nil) if object.instance_of?(Hash) @structure = object init_provenance_defaults(@structure) else @structure = {} @structure[:about] = object @structure[:annotation] = UUID.generate(:urn) @structure[:content] = content end end
Public Instance Methods
annotation_id → String
click to toggle source
Return the annotation id of this Annotation.
# File lib/ro-bundle/ro/annotation.rb, line 68 def annotation_id @structure[:annotation] end
content
click to toggle source
The identifier for a resource that contains the body of the annotation.
# File lib/ro-bundle/ro/annotation.rb, line 52 def content @structure[:content] end
content = new_content
click to toggle source
Set the content of this annotation.
# File lib/ro-bundle/ro/annotation.rb, line 60 def content=(new_content) @structure[:content] = new_content end
target
click to toggle source
The identifier for the annotated resource. This is considered the target of the annotation, that is the resource the annotation content is “somewhat about”.
# File lib/ro-bundle/ro/annotation.rb, line 44 def target @structure[:about] end
to_json(options = nil) → String
click to toggle source
Write this Annotation out as a json string. Takes the same options as JSON#generate.
# File lib/ro-bundle/ro/annotation.rb, line 77 def to_json(*a) Util.clean_json(@structure).to_json(*a) end