From: Brian Candler Date: 2011-05-11T17:39:14+09:00 Subject: Re: Starting Method/Class issues 7stud -- wrote in post #997840: > Next, instead of using a variable inside a string, you can also call a > function: > > def verify(x) > if x > 15 > 'valid' > else > 'invalid' > end > end And another step, say if the number 15 is a property which you want to set, is to make a class. class Verifier def initialize(threshold) @threshold = threshold end def verify(x) if x > @threshold 'valid' else 'invalid' end end end v1 = Verifier.new(15) puts v1.verify(20) v2 = Verifier.new(25) puts v2.verify(20) The Verifier instance objects, v1 and v2, wrap up the 'verify' method with some state (instance variable @threshold) which can be used when that method is called. In your case, you might want to build a class with an @ie instance variable, so that the methods can have access to @ie without having to pass it in each time. -- Posted via http://www.ruby-forum.com/.