AFAIK that shouldn't work in MRI either

+ C:\dev
» irb
irb(main):001:0> require 'erb'
=> true
irb(main):002:0>
irb(main):003:0* data = { :version => RUBY_PLATFORM }
=> {:version=>"i386-mingw32"}
irb(main):004:0>
irb(main):005:0* class Hash
irb(main):006:1>   def method_missing(method,*args)
irb(main):007:2>     if (keys.include?(method) && args.empty?)
irb(main):008:3>       self[method]
irb(main):009:3>     else
irb(main):010:3*       super
irb(main):011:3>     end
irb(main):012:2>   end
irb(main):013:1> end
=> nil
irb(main):014:0>
irb(main):015:0* x = 42
=> 42
irb(main):016:0> template = ERB.new <<-EOF
irb(main):017:0"   The value of x is: <%= version %>
irb(main):018:0" EOF
=> #<ERB:0x26a53e0 @safe_level=nil, @src="#coding:CP850\n_erbout = '';
_erbout.concat \"  The value of x is: \"; _erbout.concat(( version ).to_s);
_erbout.concat \"\\n\"\n; _erbout.force_encoding(__ENCODING__)",
@enc=#<Encoding:CP850>, @filename=nil>
irb(main):019:0> puts template.result(data.send(:binding))
NameError: undefined local variable or method `version' for main:Object
        from (erb):1
        from C:/Ruby/lib/ruby/1.9.1/erb.rb:753:in `eval'
        from C:/Ruby/lib/ruby/1.9.1/erb.rb:753:in `result'
        from (irb):19
        from C:/Ruby/bin/irb:12:in `<main>'
irb(main):020:0>

---
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)



On Sat, Jan 30, 2010 at 2:09 PM, Thibaut Barrère
<thibaut.barr...@gmail.com>wrote:

> Hello,
>
> maybe someone can shed some light on that - the question is: is there a
> setting to make IronRuby works the same way MRI Ruby does by default for
> what I'm describing below ? I don't think it's a bug (but well maybe it is,
> just wondering).
>
> Using this script http://gist.github.com/290538 , MRI has a different
> behaviour than JRuby or IronRuby.
>
> The script will work just fine in MRI, whereas in JR/IR you'll get:
>
> (erb):2: undefined local variable or method `version' for main:Object
> (NameError)
>     from :1:in `eval'
>     from /opt/local/share/java/jruby/lib/ruby/1.8/erb.rb:743:in `result'
>     from binding-error.rb:19
>
> (erb):1: undefined method `version' for main:Object (NoMethodError)
>         from C:/IronRuby/lib/ruby/1.8/erb.rb:716:in `result'
>         from binding-error.rb:19
>         from :0:in `eval'
>
> It's just like values.send(:binding) is doing nothing.
>
> any thoughts ?
>
> thanks,
>
> -- Thibaut
>
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core@rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
>
>
_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core

Reply via email to