1
0
Fork 0
mirror of https://github.com/Luzifer/sii.git synced 2024-12-20 16:11:17 +00:00

Add selector methods

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2019-12-24 15:07:01 +01:00
parent 6202f0dedf
commit a7132e54bd
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

21
unit.go
View file

@ -36,3 +36,24 @@ func (r *RawBlock) UnmarshalSII(in []byte) error {
type Unit struct {
Entries []Block
}
func (u Unit) BlocksByClass(class string) []Block {
var out []Block
for _, b := range u.Entries {
if b.Class() == class {
out = append(out, b)
}
}
return out
}
func (u Unit) BlockByName(name string) Block {
for _, b := range u.Entries {
if b.Name() == name {
return b
}
}
return nil
}