Class: BlacklightIiifSearch::IiifSearchAnnotation
- Inherits:
-
Object
- Object
- BlacklightIiifSearch::IiifSearchAnnotation
- Includes:
- AnnotationBehavior, IIIF::Presentation
- Defined in:
- app/models/blacklight_iiif_search/iiif_search_annotation.rb
Instance Attribute Summary collapse
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#hl_index ⇒ Object
readonly
Returns the value of attribute hl_index.
-
#parent_document ⇒ Object
readonly
Returns the value of attribute parent_document.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#snippet ⇒ Object
readonly
Returns the value of attribute snippet.
Instance Method Summary collapse
- #as_hash ⇒ IIIF::Presentation::Annotation
-
#initialize(document, query, hl_index, snippet, controller, parent_document) ⇒ IiifSearchAnnotation
constructor
rubocop:disable Metrics/ParameterLists.
- #text_resource_for_annotation ⇒ IIIF::Presentation::Resource
Methods included from AnnotationBehavior
#annotation_id, #canvas_uri_for_annotation, #coordinates
Constructor Details
#initialize(document, query, hl_index, snippet, controller, parent_document) ⇒ IiifSearchAnnotation
rubocop:disable Metrics/ParameterLists
20 21 22 23 24 25 26 27 |
# File 'app/models/blacklight_iiif_search/iiif_search_annotation.rb', line 20 def initialize(document, query, hl_index, snippet, controller, parent_document) @document = document @query = query @hl_index = hl_index @snippet = snippet @controller = controller @parent_document = parent_document end |
Instance Attribute Details
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
9 10 11 |
# File 'app/models/blacklight_iiif_search/iiif_search_annotation.rb', line 9 def controller @controller end |
#document ⇒ Object (readonly)
Returns the value of attribute document.
9 10 11 |
# File 'app/models/blacklight_iiif_search/iiif_search_annotation.rb', line 9 def document @document end |
#hl_index ⇒ Object (readonly)
Returns the value of attribute hl_index.
9 10 11 |
# File 'app/models/blacklight_iiif_search/iiif_search_annotation.rb', line 9 def hl_index @hl_index end |
#parent_document ⇒ Object (readonly)
Returns the value of attribute parent_document.
9 10 11 |
# File 'app/models/blacklight_iiif_search/iiif_search_annotation.rb', line 9 def parent_document @parent_document end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
9 10 11 |
# File 'app/models/blacklight_iiif_search/iiif_search_annotation.rb', line 9 def query @query end |
#snippet ⇒ Object (readonly)
Returns the value of attribute snippet.
9 10 11 |
# File 'app/models/blacklight_iiif_search/iiif_search_annotation.rb', line 9 def snippet @snippet end |
Instance Method Details
#as_hash ⇒ IIIF::Presentation::Annotation
32 33 34 35 36 37 |
# File 'app/models/blacklight_iiif_search/iiif_search_annotation.rb', line 32 def as_hash annotation = IIIF::Presentation::Annotation.new('@id' => annotation_id) annotation.resource = text_resource_for_annotation if snippet annotation['on'] = canvas_uri_for_annotation annotation end |
#text_resource_for_annotation ⇒ IIIF::Presentation::Resource
41 42 43 44 45 |
# File 'app/models/blacklight_iiif_search/iiif_search_annotation.rb', line 41 def text_resource_for_annotation clean_snippet = ActionView::Base.full_sanitizer.sanitize(snippet) IIIF::Presentation::Resource.new('@type' => 'cnt:ContentAsText', 'chars' => clean_snippet) end |