The following code shows an example of embedded evaluation in double-quoted strings.
For example, here we have created an object, ob, from a custom class, MyClass, and used embedded evaluation to display the values of its name and number attributes:
class MyClass attr_accessor :name # www. j a va 2 s . c o m attr_accessor :number def initialize( aName, aNumber ) @name = aName @number = aNumber end end ob = MyClass.new( "Java", "007" ) puts( "My name is #{ob.name} and my number is #{ob.number}" )