Class: LD4L::OpenAnnotationRDF::CommentAnnotation

Inherits:
Annotation
  • Object
show all
Defined in:
lib/ld4l/open_annotation_rdf/comment_annotation.rb

Instance Method Summary collapse

Methods inherited from Annotation

#getBody, #persist!, resume, #setAnnotatedAtNow

Constructor Details

#initialize(*args) ⇒ CommentAnnotation

Special processing for new and resumed CommentAnnotations



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ld4l/open_annotation_rdf/comment_annotation.rb', line 30

def initialize(*args)
  super(*args)

  # set motivatedBy
  m = get_values(:motivatedBy)
  set_value(:motivatedBy, RDFVocabularies::OA.commenting) unless m.kind_of?(Array) && m.size > 0

  # resume CommentBody if it exists
  comment_uri = get_values(:hasBody).first
  if( comment_uri )
    comment_uri = comment_uri.rdf_subject  if comment_uri.kind_of?(ActiveTriples::Resource)
    @body  = LD4L::OpenAnnotationRDF::CommentBody.new(comment_uri)
  end
end

Instance Method Details

#setComment(comment) ⇒ Object

Create a comment annotation body and set the hasBody property to it.

Parameters:

  • (String)

Returns:

  • instance of SemanticTagBody



16
17
18
19
20
21
22
23
24
25
# File 'lib/ld4l/open_annotation_rdf/comment_annotation.rb', line 16

def setComment(comment)
  @body = LD4L::OpenAnnotationRDF::CommentBody.new(
      ActiveTriples::LocalName::Minter.generate_local_name(
          LD4L::OpenAnnotationRDF::CommentBody, 10, @localname_prefix,
          LD4L::OpenAnnotationRDF.configuration.localname_minter ))
  @body.content = comment
  @body.format  = "text/plain"
  set_value(:hasBody, @body)
  @body
end