[Ironruby-core] undefined Method 'downcase'

Ivan Porto Carrero ivan at flanders.co.nz
Wed Mar 18 18:36:22 EDT 2009


A CLR string is not the same as a ruby string. Calling .to_s before downcase
should work or you can monkey patch System::String  and add the method
downcase to the clr string class if it bothers you too much


class System::String

  def downcase
     self.to_s.downcase
  end

end

On Wed, Mar 18, 2009 at 11:10 PM, Marco Kotrotsos <lists at ruby-forum.com>wrote:

>
>
> Hi and goodevening, hope someone can help
>
> i am trying to get some sort of scripting support going. I have the
> following code, which executes a ruby method and return the result.
> However, it is returning a method not found error from IronRuby itself
>
> some code ommited but it's based on the standard example. (I did make
> reference to all the dlls IronRuby and IronRuby.Libraries)
>
> var engine = IronRuby.Ruby.CreateEngine();
> returnvalue = engine.Operations.InvokeMember(instance, method,
> arg).ToString();
>
>
>
> I am running the following ruby code as a test...
>
> class Plotlight
> def get_message(a)
> res = "Hello- from Ruby " << a
> res
> end
>
> def swapcase(a)
> res = a.downcase
> res
> end
> end
>
> Now, when running the method get_message("something") things work great
> however when running something that has a reference to the standard
> library (swapcase in this example) it will return the error
>
> $exception {"undefined method `downcase' for fooBAR:ClrString"}
> System.Exception {System.MissingMethodException}
>
> running the code through ir.exe works without any problems
>
> Do I need to make a call/reference to the library? and if I do, how do I
> do that?
>
> Hope someone can help! Thank you very much.
>
> Kind regards, Marco
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> 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/20090318/029c88f6/attachment.html>


More information about the Ironruby-core mailing list