Class: BioInterchange::TextMining::Document

Inherits:
Model
  • Object
show all
Defined in:
lib/biointerchange/textmining/document.rb

Instance Method Summary collapse

Methods inherited from Model

#prune

Constructor Details

#initialize(uri) ⇒ Document

Creates a blank document representation.

uri

source of the document



8
9
10
11
12
13
# File 'lib/biointerchange/textmining/document.rb', line 8

def initialize(uri)
  @uri = uri

  # Will hold content:
  @content = []
end

Instance Method Details

#add(content) ⇒ Object

Adds content to the document.

content

content of type BioInterchange::TextMining::Content that should be added to the document



23
24
25
26
27
28
# File 'lib/biointerchange/textmining/document.rb', line 23

def add(content)
  if ( (! content.kind_of?(BioInterchange::TextMining::Content)) && (! content.kind_of?(BioInterchange::TextMining::ContentConnection)) )
    raise BioInterchange::Exceptions::ImplementationModelError, 'Content has to be of kind BioInterchange::TextMining::Content or kind BioInterchange::TextMining::ContentConnection' 
  end
  @content << content
end

#contentsObject

Returns the document contents as an array.



31
32
33
# File 'lib/biointerchange/textmining/document.rb', line 31

def contents
  @content.clone.freeze
end

#uriObject

Returns the URI of the document.



16
17
18
# File 'lib/biointerchange/textmining/document.rb', line 16

def uri
  @uri
end