feat(aa): add basic rules getter

This commit is contained in:
Alexandre Pujol 2024-05-05 14:11:00 +01:00
parent ad81c39e31
commit 3ad55927bf
No known key found for this signature in database
GPG Key ID: C5469996F0DF68EC

View File

@ -32,3 +32,24 @@ type Rules []Rule
func (r Rules) String() string {
return renderTemplate("rules", r)
}
func (r Rules) Get(filter string) Rules {
res := make(Rules, 0)
for _, rule := range r {
if rule.Kind() == filter {
res = append(res, rule)
}
}
return res
}
func (r Rules) GetVariables() []*Variable {
res := make([]*Variable, 0)
for _, rule := range r {
switch rule.(type) {
case *Variable:
res = append(res, rule.(*Variable))
}
}
return res
}