// this is just intended to give a little more OOP structure to a script.
// put most code inside of run(), plus class variables and methods.
class Script {
private String hello = "Hello"
public Script run(Map options = [:]) {
println "$hello ${options.name ?: 'World'}${shout(23)}"
return this // for method chaining
}
private String shout(int times = 1) {
return ('!' * times)
}
}
new Script()
.run()
.run([name:'Crazy4Groovy'])
println 'DONE'
Showing posts with label template. Show all posts
Showing posts with label template. Show all posts
Monday, June 17, 2013
Script template
Subscribe to:
Posts (Atom)