# Invloking Ruby Methods From C

**URL:** <https://www.ruby-forum.com/t/invloking-ruby-methods-from-c/182002>\
**Category:** Ruby\
**Created:** [January 21, 2010, 11:44am UTC](https://www.ruby-forum.com/t/invloking-ruby-methods-from-c/182002 "2010-01-21T11:44:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![coldpeace](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f4b2a3/32.png) [@coldpeace](https://www.ruby-forum.com/u/coldpeace)\
**Post date:** [January 21, 2010, 11:44am UTC](https://www.ruby-forum.com/t/invloking-ruby-methods-from-c/182002/1 "2010-01-21T11:44:27Z")

</div>

Hi ,  
I have a Stupid Question !!  
I’d like to know how to invoke a Ruby methode from a C code .

Ok, you may tell me to use \> rb\_funcall !!  
exactely that wht I want to do!!

but if I have My Ruby Script.rb SomWhere , with a function called euh…  
Test() i.e ,  
how can I tell the rb\_funcall function to invoke the test method in the  
Scipt.rb

Thx 😉

---

<div class="post-metadata">

**Author:** ![coldpeace](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f4b2a3/32.png) [@coldpeace](https://www.ruby-forum.com/u/coldpeace)\
**Post date:** [January 22, 2010, 12:02am UTC](https://www.ruby-forum.com/t/invloking-ruby-methods-from-c/182002/2 "2010-01-22T00:02:50Z")

</div>

> I’d like to know how to invoke a Ruby methode from a C code .
> 
> Ok, you may tell me to use \> rb\_funcall !!  
> exactely that wht I want to do!!

typically you’ll have a

(VALUE something)  
then it’s like

rb\_funcall(something, rb\_intern(“method\_name”), arg1, arg2)

where arg1 and arg2 are also ruby VALUE’s

checkout the file README.EXT it might be helpful.

There’s also an rb\_eval\_string(“some ruby code”)

or like  
rb\_eval\_string("$abc.some\_method")

if that helps.  
-r
