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:
parent
6202f0dedf
commit
a7132e54bd
1 changed files with 21 additions and 0 deletions
21
unit.go
21
unit.go
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue