On Thursday 01 November 2012 Justin Gamble wrote
> Hello,
> 
> im working on code to check if a character is a consonant or not and if
> it is to put a number after each one. This is what ive got so far.
> 
> class Num
> 
>   def to_num( c )
>     c.each do |c|
>       if c =~ /![aeiou]/
>         c.join( "0" )
>       end
>     end
>   end
> 
> end
> 
> Num.to_num( "Wow! Look at this get a number after each letter!" ) { |c|
> print c}
> 
> I keep getting the undefined method to_num for Num:class
> 
> Any suggestions on what i can do to get this to work? Any help is
> appreciated! Thanks!
> 
> --
> Posted via http://www.ruby-forum.com/.

That's because to_num is an instance method (that is, a method defined on 
instances of class Num) rather than a method of the class itself. You can 
solve the problem in two ways:
* create an instance of num and call its to_num method:
  n = Num.new
  n.to_num
* define to_num as a class method:
  class Num
    def self.to_num  #note the self!
      ...

Also note that your regexp won't work as you expected. To match a character 
other than those included in a list, you need to put a ^ at the beginning of 
the list:
  if c =~ /[^aeiou]/

I hope this helps

Stefano