Skip to content

Commit 312fc9d

Browse files
committed
Fraction: Added stringValue property
1 parent 5e7b292 commit 312fc9d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Sources/TimecodeKit/Utilities/Fraction.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ public struct Fraction {
9090
public var decimalValue: Decimal {
9191
Decimal(numerator) / Decimal(denominator)
9292
}
93+
94+
/// Returns the fraction as a human-readable string.
95+
/// ie: "1/2"
96+
public var stringValue: String {
97+
"\(numerator)/\(denominator)"
98+
}
9399
}
94100

95101
extension Fraction: Equatable {
@@ -130,7 +136,7 @@ extension Fraction: Sendable { }
130136

131137
extension Fraction: CustomStringConvertible {
132138
public var description: String {
133-
"\(numerator)/\(denominator)"
139+
stringValue
134140
}
135141
}
136142

0 commit comments

Comments
 (0)