timestamper/src/main/com/jdbernard/timeanalyzer/TwoLevelCategory.groovy
2011-01-18 17:58:29 -06:00

25 lines
531 B
Groovy

package com.jdbernard.timeanalyzer
public class TwoLevelCategory extends Category {
private final def descriptionPattern
public TwoLevelCategory(String heading) {
super(heading)
descriptionPattern = ~/^${heading}:\s*(.*)/
}
public boolean matchesEvent(Event e) {
return e.description ==~ descriptionPattern
}
public Event addEvent(Event e) {
def m = e.description =~ descriptionPattern
e = new Event(e, description: m[0][1])
super.addEvent(e)
}
}