Thibaut Schmitt 279f13dbd5
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
Add SwiftLint HARD rules
2025-04-30 17:05:02 +02:00

47 lines
1017 B
Swift

//
// Section.swift
//
//
// Created by Thibaut Schmitt on 04/01/2022.
//
import Foundation
class Section {
// MARK: - Properties
let name: String // OnBoarding
var definitions = [Definition]()
// MARK: - Init
init(name: String) {
self.name = name
}
// MARK: - Methods
static func match(_ line: String) -> Section? {
guard line.range(of: "\\[\\[(.*?)]]$", options: .regularExpression, range: nil, locale: nil) != nil else {
return nil
}
let sectionName = line
.replacingOccurrences(of: ["[", "]"], with: "")
.removeLeadingTrailingWhitespace()
return Section(name: sectionName)
}
func hasOneOrMoreMatchingTags(tags: [String]) -> Bool {
let allTags = definitions.flatMap { $0.tags }
let allTagsSet = Set(allTags)
let intersection = Set(tags).intersection(allTagsSet)
if intersection.isEmpty {
return false
}
return true
}
}