class Xliffle::Creator
Attributes
files[R]
Public Class Methods
new()
click to toggle source
# File lib/xliffle/creator.rb, line 10 def initialize @files = [] end
Public Instance Methods
file(original, source_locale, target_locale)
click to toggle source
# File lib/xliffle/creator.rb, line 14 def file(original, source_locale, target_locale) file = Xliffle::File.new(original, source_locale, target_locale) @files << file file end
to_file()
click to toggle source
# File lib/xliffle/creator.rb, line 28 def to_file handle = Tempfile.new('foo.xlf') handle.write to_xliff handle.close handle end
to_xliff()
click to toggle source
# File lib/xliffle/creator.rb, line 20 def to_xliff xml do |xml| @files.each do |file| file.to_xliff xml end end end
Private Instance Methods
file_id()
click to toggle source
# File lib/xliffle/creator.rb, line 37 def file_id @files.length.succ end
xml(&block)
click to toggle source
# File lib/xliffle/creator.rb, line 41 def xml(&block) xml = Builder::XmlMarkup.new(indent: 2) xml.instruct! :xml, encoding: 'UTF-8' xml.xliff({ version: '1.2', xmlns: 'urn:oasis:names:tc:xliff:document:1.2' }, &block) end