title: Undefined method NoMethodError
body: <p>I was just playing around w/Ruby and attempting to create a function but for some reason it is not working the way I thought it would. Not sure why I'm having this problem but here is my code :</p>
  
  <pre><code>class Script
    print "Enter a number: "
    number = gets
  
    def random (temp)
        puts "#{temp}"
        puts "inside function"
    end
  
    random (number)
  end
  </code></pre>
  
  <p>Error :</p>
  
  <pre><code>Script.rb:13:in `&lt;class:Script&gt;': undefined method `random' for Script:Class (NoMethodError)
  from Script.rb:1:in `&lt;main&gt;'
  </code></pre>