Module: EBPS::Conversion::ImportModuleSample
- Defined in:
- lib/ebps/conversion/import_module_sample.rb
Class Method Summary collapse
- .assemble_document(chapters, yaml_value) ⇒ Object
- .encode(txt) ⇒ Object
- .import(string_or_io, path = nil) ⇒ Object
Class Method Details
.assemble_document(chapters, yaml_value) ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/ebps/conversion/import_module_sample.rb', line 70 def self.assemble_document chapters, yaml_value doc = Text::Document.new doc.title = Conversion::ImportModuleSample.encode(yaml_value['name']) chapters.each do |name| if chapter = yaml_value[name] doc.add_chapter chapter end end doc end |
.encode(txt) ⇒ Object
80 81 82 83 |
# File 'lib/ebps/conversion/import_module_sample.rb', line 80 def self.encode txt txt.force_encoding 'UTF-8' txt end |
.import(string_or_io, path = nil) ⇒ Object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/ebps/conversion/import_module_sample.rb', line 60 def self.import string_or_io, path=nil collection = {} YAML.each_document string_or_io do |doc| if doc collection.store Digest::MD5.hexdigest(doc.to_s), doc end end ## apparently we have some nil-values here (?) collection.values.compact end |