Skip to content

Commit

Permalink
create PrinterType from Capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
gmuth committed Dec 11, 2024
1 parent 756dc67 commit 6bd071b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/kotlin/de/gmuth/ipp/attributes/PrinterType.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package de.gmuth.ipp.attributes

/**
* Copyright (c) 2020-2023 Gerhard Muth
* Copyright (c) 2020-2024 Gerhard Muth
*/

import de.gmuth.ipp.core.IppAttribute
Expand Down Expand Up @@ -68,6 +68,10 @@ class PrinterType(val value: Int) : IppAttributeBuilder {
companion object {
fun fromAttributes(attributes: IppAttributesGroup) =
PrinterType(attributes.getValue("printer-type"))
}

fun fromCapabilities(capabilities: Set<Capability>) = capabilities
.map { 1 shl it.bit }
.reduce { c1, c2 -> c1 + c2 }
.let { PrinterType(it) }
}
}

0 comments on commit 6bd071b

Please sign in to comment.