#!/usr/bin/env ruby
require 'erb'
document = %[
<%= @name %>
<%= @name %>
Breed: <%= @breed %>
Sex: <%= @sex %>
Foals
<% @foals.each do |foals| %>
- <%= foals %>
<% end %>
]
class Horse
def initialize( name, breed, sex )
@name = name
@breed = breed
@sex = sex
@foals = []
end
def foal( name )
@foals << name
end
def context
binding
end
end
output = ERB.new( document )
horse = Horse.new( "A", "Q", "M" )
horse.foal( "D" )
horse.foal( "P" )
output.run( horse.context )