Class: Calc_c

Inherits:
Object
  • Object
show all
Defined in:
ext/calc/calc.c

Class Method Summary collapse

Class Method Details

.palindrom?(string_raw) ⇒ Boolean

the palindrom function can be called from ruby as “Calc_c.palindrom?”

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
17
18
19
20
# File 'ext/calc/calc.c', line 9

static VALUE palindrom(VALUE self, VALUE string_raw)
{
   char *string = StringValuePtr(string_raw);
   int result;
 
   result = is_palindrome(string);
 
   if ( result == 1 )
      return Qtrue;
   else
      return Qfalse;
}