timestamper/src/main/com/jdbernard/timeanalyzer/TwoLevelCategory.groovy

25 lines
531 B
Groovy
Raw Normal View History

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
}
2011-01-18 17:58:29 -06:00
public Event addEvent(Event e) {
def m = e.description =~ descriptionPattern
e = new Event(e, description: m[0][1])
2011-01-18 17:58:29 -06:00
super.addEvent(e)
}
}