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