Class: Glossarist::Transforms::ConceptToTbxTransform
- Inherits:
-
Object
- Object
- Glossarist::Transforms::ConceptToTbxTransform
- Defined in:
- lib/glossarist/transforms/concept_to_tbx_transform.rb
Class Method Summary collapse
- .transform(managed_concept, options = {}) ⇒ Object
- .transform_document(concepts, options = {}) ⇒ Object
Instance Method Summary collapse
- #build_entry ⇒ Object
-
#initialize(managed_concept, options = {}) ⇒ ConceptToTbxTransform
constructor
A new instance of ConceptToTbxTransform.
Constructor Details
#initialize(managed_concept, options = {}) ⇒ ConceptToTbxTransform
Returns a new instance of ConceptToTbxTransform.
35 36 37 38 |
# File 'lib/glossarist/transforms/concept_to_tbx_transform.rb', line 35 def initialize(managed_concept, = {}) @concept = managed_concept @options = end |
Class Method Details
.transform(managed_concept, options = {}) ⇒ Object
8 9 10 |
# File 'lib/glossarist/transforms/concept_to_tbx_transform.rb', line 8 def self.transform(managed_concept, = {}) new(managed_concept, ).build_entry end |
.transform_document(concepts, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/glossarist/transforms/concept_to_tbx_transform.rb', line 12 def self.transform_document(concepts, = {}) doc = Tbx::Document.new body = Tbx::Body.new body.concept_entry = concepts.map { |c| transform(c, ) } text = Tbx::TextElement.new text.body = body doc.text = text if [:title] header = doc.tbx_header || Tbx::TbxHeader.new file_desc = Tbx::FileDesc.new title_stmt = Tbx::TitleStmt.new title = Tbx::Title.new title.content = [:title] title_stmt.title = title file_desc.title_stmt = title_stmt header.file_desc = file_desc doc.tbx_header = header end doc end |
Instance Method Details
#build_entry ⇒ Object
40 41 42 43 44 45 |
# File 'lib/glossarist/transforms/concept_to_tbx_transform.rb', line 40 def build_entry entry = Tbx::ConceptEntry.new entry.id = concept_id entry.lang_sec = build_lang_sections entry end |