Ruby program to implement the getter method
class Sample
#constructor
def initialize(val)
@ins_var = val;
end
#Getter method
def GetVal
@ins_var
end
end
obj = Sample.new("Hello");
val = obj.GetVal();
print "Value is: ",val;
Output:
Value is: Hello
