Class: DocFrac::Convert
- Inherits:
-
Object
- Object
- DocFrac::Convert
- Defined in:
- lib/doc_frac/convert.rb
Instance Attribute Summary collapse
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #convert ⇒ Object
-
#initialize(from, to) ⇒ Convert
constructor
A new instance of Convert.
Constructor Details
Instance Attribute Details
#text ⇒ Object
Returns the value of attribute text.
3 4 5 |
# File 'lib/doc_frac/convert.rb', line 3 def text @text end |
Instance Method Details
#convert ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/doc_frac/convert.rb', line 10 def convert from_file = "/tmp/#{DocFrac::Utilities.random_string}.#{@from_format.ext}" to_file = "/tmp/#{DocFrac::Utilities.random_string}.#{@to_format.ext}" File.open(from_file, "w") {|f| f.write(@text) } `docfrac #{@from_format.format_text} #{from_file} #{@to_format.format_text} #{to_file}` file = File.open(to_file, "r").read File.delete(from_file, to_file) return file end |