feat(aa): add basic rules getter
This commit is contained in:
parent
ad81c39e31
commit
3ad55927bf
1 changed files with 21 additions and 0 deletions
|
|
@ -32,3 +32,24 @@ type Rules []Rule
|
||||||
func (r Rules) String() string {
|
func (r Rules) String() string {
|
||||||
return renderTemplate("rules", r)
|
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
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue