Method: Command::Diff#create_temp_by_sections

Defined in:
lib/command/diff.rb

#create_temp_by_sections(temp_prefix, sections, novel_info) ⇒ Object



224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/command/diff.rb', line 224

def create_temp_by_sections(temp_prefix, sections, novel_info)
  html = HTML.new
  html.strip_decoration_tag = true
  sections.each do |section|
    element = section["element"]
    data_type = element.delete("data_type") || "text"
    element.each do |text_type, elm_text|
      if data_type == "html"
        html.string = elm_text
        element[text_type] = html.to_aozora
      end
    end
  end
  temp = Tempfile.open([temp_prefix, ".txt"])
  temp.write(Template.get("diff.txt", binding, 1.0))
  temp.close
  temp
end