Class: ODF::Converter
- Inherits:
-
Object
- Object
- ODF::Converter
- Defined in:
- lib/odf/converter.rb,
lib/odf/converter/version.rb,
lib/odf/converter/families.rb,
lib/odf/converter/filters/export.rb,
lib/odf/converter/filters/import.rb,
lib/odf/converter/filters/base_filter.rb
Defined Under Namespace
Modules: Families, Filters Classes: DocumentConversionError
Constant Summary collapse
- VERSION =
"0.0.3"
Instance Attribute Summary collapse
-
#ctx ⇒ Object
readonly
Returns the value of attribute ctx.
-
#desktop ⇒ Object
readonly
Returns the value of attribute desktop.
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#smgr ⇒ Object
readonly
Returns the value of attribute smgr.
Class Method Summary collapse
Instance Method Summary collapse
- #convert(infile, options = {}) ⇒ Object
-
#initialize ⇒ Converter
constructor
A new instance of Converter.
- #inspect ⇒ Object
Constructor Details
#initialize ⇒ Converter
Returns a new instance of Converter.
16 17 18 19 20 21 |
# File 'lib/odf/converter.rb', line 16 def initialize config = ODF.config @ctx = Uno::Connector.bootstrap(config.office_bin.to_s, config.connection_type.to_s, config.host.to_s, config.port) @smgr = @ctx.getServiceManager @desktop = @smgr.createInstanceWithContext("com.sun.star.frame.Desktop", @ctx) end |
Instance Attribute Details
#ctx ⇒ Object (readonly)
Returns the value of attribute ctx.
14 15 16 |
# File 'lib/odf/converter.rb', line 14 def ctx @ctx end |
#desktop ⇒ Object (readonly)
Returns the value of attribute desktop.
14 15 16 |
# File 'lib/odf/converter.rb', line 14 def desktop @desktop end |
#document ⇒ Object (readonly)
Returns the value of attribute document.
14 15 16 |
# File 'lib/odf/converter.rb', line 14 def document @document end |
#smgr ⇒ Object (readonly)
Returns the value of attribute smgr.
14 15 16 |
# File 'lib/odf/converter.rb', line 14 def smgr @smgr end |
Class Method Details
.convert(*args) ⇒ Object
42 43 44 |
# File 'lib/odf/converter.rb', line 42 def self.convert(*args) new.convert(*args) end |
Instance Method Details
#convert(infile, options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/odf/converter.rb', line 23 def convert(infile, = {}) raise ArgumentError, "to option must be provided." unless [:to] if [:to].is_a? Symbol #and Filters::Export[options[:to]] outfile = get_output_name(infile, [:to]) elsif [:to].is_a? String raise DocumentConversionError, "#{[:to]} doesn't specify an extension" if File.extname([:to]).empty? outfile = File.([:to]) else raise DocumentConversionError, "not given a valid destination" end perform_conversion(infile, outfile) && outfile end |
#inspect ⇒ Object
38 39 40 |
# File 'lib/odf/converter.rb', line 38 def inspect "#<#{self.class.name} #{self.class.config.office_bin}@#{self.class.config.host}:#{self.class.config.port}>" end |