Hello
Can anyone see why I can''t include System in this little script? If
I do
I get an exception ''Converter is not a class (TypeError)''. If
I skip the
include and fully qualify the classes in that namespace this works
perfectly.
Thanks for your time and ideas,
Patrick
require ''System, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089''
require ''Microsoft.Office.Interop.Word, Version=12.0.0.0,
Culture=neutral,
PublicKeyToken=71e9bce111e9429c''
include System
include Microsoft::Office::Interop::Word
class Converter
def Convert(inputDirectories, outputDirectory)
word = ApplicationClass.new
inputDirectories.each {|inputDirectory|
Directory.GetFiles(inputDirectory, ''*.doc'').each { |file|
documentPath = System::IO::Path.Combine(outputDirectory,
Path.GetFileNameWithoutExtension(file) + ".xps")
word.Documents.Open(file)
word.ActiveDocument.SaveAs(documentPath, WdSaveFormat.wdFormatXPS)
word.ActiveDocument.Close()
}
word.Quit()
}
end
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/ironruby-core/attachments/20091120/701c99b1/attachment.html>
Converter is a *delegate *type in the System namespace (it comes from
mscorlib.dll, not System.dll). You should probably put your class in a
custom namespace like so:
module MyModule
class Converter
...
end
end
On Fri, Nov 20, 2009 at 10:39 AM, Patrick Brown <patrickcbrown at
gmail.com>wrote:
> Hello
>
> Can anyone see why I can''t include System in this little
script? If I
> do I get an exception ''Converter is not a class
(TypeError)''. If I skip the
> include and fully qualify the classes in that namespace this works
> perfectly.
>
> Thanks for your time and ideas,
> Patrick
>
>
>
> require ''System, Version=2.0.0.0, Culture=neutral,
> PublicKeyToken=b77a5c561934e089''
> require ''Microsoft.Office.Interop.Word, Version=12.0.0.0,
Culture=neutral,
> PublicKeyToken=71e9bce111e9429c''
>
> include System
> include Microsoft::Office::Interop::Word
>
> class Converter
> def Convert(inputDirectories, outputDirectory)
> word = ApplicationClass.new
>
> inputDirectories.each {|inputDirectory|
> Directory.GetFiles(inputDirectory, ''*.doc'').each {
|file|
> documentPath = System::IO::Path.Combine(outputDirectory,
> Path.GetFileNameWithoutExtension(file) + ".xps")
>
> word.Documents.Open(file)
> word.ActiveDocument.SaveAs(documentPath, WdSaveFormat.wdFormatXPS)
> word.ActiveDocument.Close()
> }
>
> word.Quit()
> }
> end
> end
>
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/ironruby-core/attachments/20091120/75381d38/attachment.html>
Converter is a static class and those are mapped to modules module Converter def self.convert(inputDirectories, outputDirectory) .... end end puts System::Converter.class #=> Module --- Met vriendelijke groeten - Best regards - Salutations Ivan Porto Carrero Blog: http://flanders.co.nz Google Wave: portocarrero.ivan at googlewave.com Twitter: http://twitter.com/casualjim Author of IronRuby in Action (http://manning.com/carrero) On Fri, Nov 20, 2009 at 4:39 PM, Patrick Brown <patrickcbrown at gmail.com>wrote:> Hello > > Can anyone see why I can''t include System in this little script? If I > do I get an exception ''Converter is not a class (TypeError)''. If I skip the > include and fully qualify the classes in that namespace this works > perfectly. > > Thanks for your time and ideas, > Patrick > > > > require ''System, Version=2.0.0.0, Culture=neutral, > PublicKeyToken=b77a5c561934e089'' > require ''Microsoft.Office.Interop.Word, Version=12.0.0.0, Culture=neutral, > PublicKeyToken=71e9bce111e9429c'' > > include System > include Microsoft::Office::Interop::Word > > class Converter > def Convert(inputDirectories, outputDirectory) > word = ApplicationClass.new > > inputDirectories.each {|inputDirectory| > Directory.GetFiles(inputDirectory, ''*.doc'').each { |file| > documentPath = System::IO::Path.Combine(outputDirectory, > Path.GetFileNameWithoutExtension(file) + ".xps") > > word.Documents.Open(file) > word.ActiveDocument.SaveAs(documentPath, WdSaveFormat.wdFormatXPS) > word.ActiveDocument.Close() > } > > word.Quit() > } > end > end > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20091120/354b2cee/attachment-0001.html>
Hi It is funny how obvious some of these things turn out to be. Thanks, Patrick On Fri, Nov 20, 2009 at 10:49 AM, Ivan Porto Carrero <ivan at flanders.co.nz>wrote:> Converter is a static class and those are mapped to modules > > module Converter > def self.convert(inputDirectories, outputDirectory) > .... > end > end > > puts System::Converter.class #=> Module > > > --- > Met vriendelijke groeten - Best regards - Salutations > Ivan Porto Carrero > Blog: http://flanders.co.nz > Google Wave: portocarrero.ivan at googlewave.com > Twitter: http://twitter.com/casualjim > Author of IronRuby in Action (http://manning.com/carrero) > > > > On Fri, Nov 20, 2009 at 4:39 PM, Patrick Brown <patrickcbrown at gmail.com>wrote: > >> Hello >> >> Can anyone see why I can''t include System in this little script? If I >> do I get an exception ''Converter is not a class (TypeError)''. If I skip the >> include and fully qualify the classes in that namespace this works >> perfectly. >> >> Thanks for your time and ideas, >> Patrick >> >> >> >> require ''System, Version=2.0.0.0, Culture=neutral, >> PublicKeyToken=b77a5c561934e089'' >> require ''Microsoft.Office.Interop.Word, Version=12.0.0.0, Culture=neutral, >> PublicKeyToken=71e9bce111e9429c'' >> >> include System >> include Microsoft::Office::Interop::Word >> >> class Converter >> def Convert(inputDirectories, outputDirectory) >> word = ApplicationClass.new >> >> inputDirectories.each {|inputDirectory| >> Directory.GetFiles(inputDirectory, ''*.doc'').each { |file| >> documentPath = System::IO::Path.Combine(outputDirectory, >> Path.GetFileNameWithoutExtension(file) + ".xps") >> >> word.Documents.Open(file) >> word.ActiveDocument.SaveAs(documentPath, WdSaveFormat.wdFormatXPS) >> word.ActiveDocument.Close() >> } >> >> word.Quit() >> } >> end >> end >> >> _______________________________________________ >> Ironruby-core mailing list >> Ironruby-core at rubyforge.org >> http://rubyforge.org/mailman/listinfo/ironruby-core >> >> > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20091120/6bf6702a/attachment.html>
Actually, System::Converter is a generic type definition for a delegate class. Generic type definitions are mapped to Ruby modules. These modules are included in all instantiations of the generic type.>>> load_assembly ''System''=> true>>> System::Converter=> System::Converter[TInput, TOutput]>>> module System::Converter... def foo ... puts ''foo'' ... end ... end => nil>>> c = System::Converter[Fixnum, String].new { |i| i.to_s }=> System.Converter`2[System.Int32,IronRuby.Builtins.MutableString]>>> c.fooFoo>>> System::Converter[Array, Hash].ancestors=> [System::Converter[Array, Hash], System::Converter[TInput, TOutput], System::MulticastDelegate, System::Delegate, System::ICloneable, System::Runtime::Serialization::ISerializable, Object, Kernel] Tomas From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Patrick Brown Sent: Friday, November 20, 2009 8:15 AM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] can''t include System Hi It is funny how obvious some of these things turn out to be. Thanks, Patrick On Fri, Nov 20, 2009 at 10:49 AM, Ivan Porto Carrero <ivan at flanders.co.nz<mailto:ivan at flanders.co.nz>> wrote: Converter is a static class and those are mapped to modules module Converter def self.convert(inputDirectories, outputDirectory) .... end end puts System::Converter.class #=> Module --- Met vriendelijke groeten - Best regards - Salutations Ivan Porto Carrero Blog: http://flanders.co.nz<http://flanders.co.nz/> Google Wave: portocarrero.ivan at googlewave.com<mailto:portocarrero.ivan at googlewave.com> Twitter: http://twitter.com/casualjim Author of IronRuby in Action (http://manning.com/carrero) On Fri, Nov 20, 2009 at 4:39 PM, Patrick Brown <patrickcbrown at gmail.com<mailto:patrickcbrown at gmail.com>> wrote: Hello Can anyone see why I can''t include System in this little script? If I do I get an exception ''Converter is not a class (TypeError)''. If I skip the include and fully qualify the classes in that namespace this works perfectly. Thanks for your time and ideas, Patrick require ''System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'' require ''Microsoft.Office.Interop.Word, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'' include System include Microsoft::Office::Interop::Word class Converter def Convert(inputDirectories, outputDirectory) word = ApplicationClass.new inputDirectories.each {|inputDirectory| Directory.GetFiles(inputDirectory, ''*.doc'').each { |file| documentPath = System::IO::Path.Combine(outputDirectory, Path.GetFileNameWithoutExtension(file) + ".xps") word.Documents.Open(file) word.ActiveDocument.SaveAs(documentPath, WdSaveFormat.wdFormatXPS) word.ActiveDocument.Close() } word.Quit() } end end _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20091120/09fe85ec/attachment-0001.html>