Class: ODDB::Text::Document
- Defined in:
- lib/oddb/text/document.rb,
lib/oddb/persistence/odba/text/document.rb
Overview
to migrate Document to be a subclass of Model:
Drugs::Sequence.all { |seq| need = false; [:fachinfo, :patinfo].each { |key| if(ml = seq.instance_variable_get("@#{key}")); need = true; seq.instance_variable_set("@#{key}", nil); if(doc = ml.de); info = seq.send(key); if(prev = doc.instance_variable_get('@previous_sources')); info.previous_sources[:de] = prev; doc.instance_eval { remove_instance_variable('@previous_sources') }; end; if((source = doc.source) && (saved = Text::Document.find_by_source(source))); doc = saved; end; info.de = doc; info.save; info.de.save; end; end }; seq.save if need }
Constant Summary
Constants included from OddbUri
Instance Attribute Summary collapse
-
#chapters ⇒ Object
readonly
Returns the value of attribute chapters.
-
#date ⇒ Object
Returns the value of attribute date.
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
- #add_chapter(chapter) ⇒ Object
- #chapter(idx_or_name) ⇒ Object
- #chapter_names ⇒ Object
-
#initialize ⇒ Document
constructor
A new instance of Document.
- #remove_chapter(chapter) ⇒ Object
- #to_s ⇒ Object
Methods inherited from Model
#__odba_delete__, #__odba_save__, _serializables, belongs_to, connections, connector, connectors, #data_origin, #data_origins, delegates, #delete, find_by_uid, has_many, is_coded, m10l_document, multilingual, #odba_serializables, #oid, on_delete, on_save, predicates, #save, #saved?, serializables, serialize, singular
Methods included from ODBA::Persistable
Methods included from Yaml
append_features, #to_yaml_properties
Methods included from OddbUri
#to_yaml, #to_yaml_map, #to_yaml_type
Constructor Details
#initialize ⇒ Document
Returns a new instance of Document.
14 15 16 |
# File 'lib/oddb/text/document.rb', line 14 def initialize @chapters = [] end |
Instance Attribute Details
#chapters ⇒ Object (readonly)
Returns the value of attribute chapters.
13 14 15 |
# File 'lib/oddb/text/document.rb', line 13 def chapters @chapters end |
#date ⇒ Object
Returns the value of attribute date.
12 13 14 |
# File 'lib/oddb/text/document.rb', line 12 def date @date end |
#source ⇒ Object
Returns the value of attribute source.
12 13 14 |
# File 'lib/oddb/text/document.rb', line 12 def source @source end |
Instance Method Details
#add_chapter(chapter) ⇒ Object
17 18 19 |
# File 'lib/oddb/text/document.rb', line 17 def add_chapter(chapter) @chapters.push chapter end |
#chapter(idx_or_name) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/oddb/text/document.rb', line 20 def chapter(idx_or_name) case idx_or_name when Integer @chapters[idx_or_name] else @chapters.find { |ch| ch.name == idx_or_name } end end |
#chapter_names ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/oddb/text/document.rb', line 28 def chapter_names @chapters.select { |chapter| chapter.paragraphs.size > 1 }.collect { |chapter| chapter.name } end |
#remove_chapter(chapter) ⇒ Object
35 36 37 |
# File 'lib/oddb/text/document.rb', line 35 def remove_chapter(chapter) @chapters.delete(chapter) end |
#to_s ⇒ Object
38 39 40 |
# File 'lib/oddb/text/document.rb', line 38 def to_s @chapters.join("\n") end |