Skip to content

Commit a5d05b2

Browse files
committed
Update MetadataQuery+AttributeValueTuple.swift
1 parent 12da869 commit a5d05b2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Sources/FZMetadata/MetadataQuery/MetadataQuery+AttributeValueTuple.swift

+10-2
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@ extension MetadataQuery {
1414

1515
Attribute-value tuples are returned by ``MetadataQuery`` as the results in the value lists. Each attribute/value tuple contains the attribute name, the value, and the number of instances of that value that exist for the attribute name.
1616
*/
17-
public struct AttributeValueTuple {
17+
public struct AttributeValueTuple: CustomStringConvertible {
1818
/// The attribute name for the tuple’s value.
1919
public let attribute: MetadataItem.Attribute
2020
/// The value of the tuple’s attribute.
2121
public let value: Any?
2222
/// The number of instances of the value for the tuple’s attribute.
2323
public let count: Int
2424

25+
public var description: String {
26+
"[value: \(value != nil ? "\(value!)": "-"), count: \(count)]"
27+
}
28+
2529
func mapped<V>(to keyPath: KeyPath<MetadataItem, V>) -> MappedAttributeValueTuple<V>? {
2630
guard let value = value as? V else { return nil }
2731
return .init(attribute, value, count)
@@ -39,14 +43,18 @@ extension MetadataQuery {
3943

4044
Attribute-value tuples are returned by ``MetadataQuery`` as the results in the value lists. Each attribute/value tuple contains the attribute name, the value, and the number of instances of that value that exist for the attribute name.
4145
*/
42-
public class MappedAttributeValueTuple<Value> {
46+
public class MappedAttributeValueTuple<Value>: CustomStringConvertible {
4347
/// The attribute name for the tuple’s value.
4448
public let attribute: MetadataItem.Attribute
4549
/// The value of the tuple’s attribute.
4650
public let value: Value
4751
/// The number of instances of the value for the tuple’s attribute.
4852
public let count: Int
4953

54+
public var description: String {
55+
"[value: \(value), count: \(count)]"
56+
}
57+
5058
init(_ attribute: MetadataItem.Attribute, _ value: Value, _ count: Int) {
5159
self.value = value
5260
self.count = count

0 commit comments

Comments
 (0)