<$BlogRSDURL$>
Metameta
Sunday, September 04, 2005
 
Having fun with ruby. When I saw I can run erb from the command line at once I had to write a erb to generate Java code. Of course Eclipse makes this particular example easy, but I'm thinking of generating unit tests with this...


C:\temp>type fun.rhtml
/**
* Module written: <%=Time.now%>
*/
public class something {
<% vars=['Jim','Potter','Zanker','Grimper'] %>
<% vars.each do |x| %> private String get<%=x.downcase%>;
<% end %><% vars.each do |x| %>
public String get<%=x%>() {
return <%=x.downcase%>;
}
<% end %>
}
C:\temp>erb fun.rhtml
/**
* Module written: Sun Sep 04 19:59:39 Eastern Daylight Time 2005
*/
public class something {

private String getjim;
private String getpotter;
private String getzanker;
private String getgrimper;

public String getJim() {
return jim;
}

public String getPotter() {
return potter;
}

public String getZanker() {
return zanker;
}

public String getGrimper() {
return grimper;
}

}


Comments: Post a Comment

Powered by Blogger

My Bookmarks: