# (C ext to Ruby) variable args count class

**URL:** <https://www.ruby-forum.com/t/c-ext-to-ruby-variable-args-count-class/111374>\
**Category:** Ruby\
**Created:** [August 6, 2007, 4:56pm UTC](https://www.ruby-forum.com/t/c-ext-to-ruby-variable-args-count-class/111374 "2007-08-06T16:56:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![unbewust](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/9d8465/32.png) [@unbewust](https://www.ruby-forum.com/u/unbewust)\
**Post date:** [August 6, 2007, 4:56pm UTC](https://www.ruby-forum.com/t/c-ext-to-ruby-variable-args-count-class/111374/1 "2007-08-06T16:56:30Z")

</div>

i have a class “RFile” with varaible aruments number (1 to 3) this  
class is defined under a module “ROSXUtils”

from the module i have three singleton :

m\_trash(one arg)

m\_move(two args)

m\_rename(three args)

in such a situation how can i play with :

rb\_class\_new\_instance(n, &arg, rb\_path2class(“RFile”)); ???

because if i put n = 2 i can see that from the class initialisation  
method

however i can’t pass de 2 args needed here ???

the same with three args

does i have to build something like an array to pass as arg ???

for m\_move by example i have :

m\_move(VALUE src\_path, VALUE dst\_dir, self)

and i want to return an RFile class object using :

rFile = rb\_class\_new\_instance(2, \<what kind of args here ???\>,  
rb\_path2class(“RFile”));

any light apreciated 😉

Yvon

---

<div class="post-metadata">

**Author:** ![unbewust](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/9d8465/32.png) [@unbewust](https://www.ruby-forum.com/u/unbewust)\
**Post date:** [August 6, 2007, 5:28pm UTC](https://www.ruby-forum.com/t/c-ext-to-ruby-variable-args-count-class/111374/2 "2007-08-06T17:28:36Z")

</div>

On 8/6/07, unbewust [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

You need an array of type VALUE (either VALUE\* or VALUE[2])

VALUE[2] args;

args[0] = your\_first\_argument;  
args[1] = your\_second\_argument;

rFile = rb\_class\_new\_instance(2, args, rb\_path2class(“RFile”));

Blessings,  
TwP

---

<div class="post-metadata">

**Author:** ![unbewust](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/9d8465/32.png) [@unbewust](https://www.ruby-forum.com/u/unbewust)\
**Post date:** [August 7, 2007, 10:27am UTC](https://www.ruby-forum.com/t/c-ext-to-ruby-variable-args-count-class/111374/3 "2007-08-07T10:27:16Z")

</div>

On 6 août, 17:27, “Tim P.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > rFile = rb\_class\_new\_instance(2, \<what kind of args here ???\>,
> 
> Blessings,  
> TwP

Ok thanks very very much !!!

I’m not too far of publishing a first alpha version of RSOXUtils for  
Ruby 😉

best,

Yvon
