1group Sample
2
3class_definition ::=
4<<<
5class <%= @name %><% if @superclass %> < <%= @superclass %><% end %>
6% if @attributes
7
8% for attr in @attributes
9<%= attribute( *attr ).to_s.chomp %>
10% end
11% end
12% if @methods
13% for method in ( @methods || [] )
14<%= method( method ) %>
15% end
16% end
17end
18>>>
19
20attribute( name, access = 'rw' ) ::=
21<<<
22% case @access.to_s.downcase
23% when 'r'
24  attr_reader :<%= @name %>
25% when 'w'
26  attr_writer :<%= @name %>
27% else
28  attr_accessor :<%= @name %>
29% end
30>>>
31
32method ::=
33<<<
34
35  def <%= @name %><% if @arguments and not @arguments.empty? %>( <%= @arguments.join( ', ' ) %> )<% end %>
36<%= @body.gsub( /^/, '    ' ) %>
37  end
38>>>
39