CLR Properties in IronRuby

How can I refer to the CLR properties in IronRuby.
public class Customer {

public string FirstName { get;set; }

}

In Ruby:

@customer.FirstName = ‘s’

OR

@customer.firstname = ‘s’

@customer.first_name = ‘s’
This is called name mangling when IronRuby make CLR name Ruby-like.

Shay.

Shay F.
Author of “IronRuby Unleashed”
http://www.IronShay.com
Follow me: http://twitter.com/ironshay

C:\temp
[42] > rbd
IronRuby 0.9.0.0 on .NET 2.0.50727.4927
Copyright © Microsoft Corporation. All rights reserved.

require ‘temp.dll’
=> true

@c = Customer.new
=> Customer

@c.FirstName
=> nil

@c.first_name
=> nil

@c.FirstName = ‘s’
=> “s”

@c.first_name
=> ‘s’

@c.FirstName
=> ‘s’

@c.first_name = ‘s’
=> “s”

@c.first_name
=> ‘s’

@c.FirstName
=> ‘s’

In particular, IR mangles CamelCase into snake_case for most .NET
methods, but it doesn’t work for pure Ruby methods. In addition, certain
builtin types, such as Object and Fixnum are the same type as
System.Object and System.Int32 (respectively), so they don’t mangle
names. When in doubt, you should always be able to call a method by its
proper .NET name, and you can use #methods to get a list of the methods
that an object responds to. (in this case, @c.methods would have
‘first_name’ and ‘first_name=’ method in the list.

JD

From: [email protected]
[mailto:[email protected]] On Behalf Of Shay F.
Sent: Wednesday, September 23, 2009 9:14 PM
To: [email protected]
Subject: Re: [Ironruby-core] CLR Properties in IronRuby

@customer.first_name = ‘s’

This is called name mangling when IronRuby make CLR name Ruby-like.

Shay.

Shay F.
Author of “IronRuby Unleashed”
http://www.IronShay.com
Follow me: http://twitter.com/ironshay
On Thu, Sep 24, 2009 at 6:59 AM, Mohammad A.
<[email protected]mailto:[email protected]> wrote:
How can I refer to the CLR properties in IronRuby.

public class Customer {

public string FirstName { get;set; }

}

In Ruby:

@customer.FirstName = ‘s’

OR

@customer.firstname = ‘s’


Mohammad A.
MVP (Microsoft Valuable Professional)
www.highoncoding.comhttp://www.highoncoding.com
www.azamsharp.comhttp://www.azamsharp.com

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs