Class: Muhimbi::Converter
- Inherits:
-
Object
- Object
- Muhimbi::Converter
- Defined in:
- lib/muhimbi/converter.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
-
#file_content ⇒ Object
Returns the value of attribute file_content.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #convert ⇒ Object
- #defaults_options(opts = {}) ⇒ Object
-
#initialize(opts = {}) ⇒ Converter
constructor
A new instance of Converter.
- #method_missing(meth, opts = {}) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Converter
Returns a new instance of Converter.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/muhimbi/converter.rb', line 10 def initialize(opts={}) unless opts[:file].blank? self.file_content = encode_file(opts[:file]) self.file = opts[:file] end self.tap do |client| client. ||= {} client.(opts) client. ||= opts yield client if block_given? end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, opts = {}) ⇒ Object
31 32 33 |
# File 'lib/muhimbi/converter.rb', line 31 def method_missing(meth, opts = {}) meth, opts end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
6 7 8 |
# File 'lib/muhimbi/converter.rb', line 6 def file @file end |
#file_content ⇒ Object
Returns the value of attribute file_content.
6 7 8 |
# File 'lib/muhimbi/converter.rb', line 6 def file_content @file_content end |
#options ⇒ Object
Returns the value of attribute options.
6 7 8 |
# File 'lib/muhimbi/converter.rb', line 6 def @options end |
Instance Method Details
#convert ⇒ Object
26 27 28 29 |
# File 'lib/muhimbi/converter.rb', line 26 def convert wsdl_res = Muhimbi::Client.client.call(:convert , message: self. ) wsdl_res.to_hash[:convert_response][:convert_result] end |
#defaults_options(opts = {}) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/muhimbi/converter.rb', line 35 def (opts={}) self.sourceFile(self.file_content) self.openOptions({ "FileExtension" => File.extname( self.file ).gsub(".", ""), "OriginalFileName"=> File.basename( self.file) }) self.conversionSettings({ "Format" => "PDF", "Fidelity"=> "Full" }) end |