Skip to content

Commit 78e5acf

Browse files
committed
Cleanup: NumericTextStyles.
1 parent b1b9575 commit 78e5acf

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

Sources/DiffableTextStylesXNumeric/Helpers/Lexicon.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ extension Lexicon {
5151
// MARK: Initializers
5252
//=------------------------------------------------------------------------=
5353

54-
/// Requires that formatter.numberStyle == .decimal.
54+
/// Requires that formatter.numberStyle == .none.
5555
@inlinable static func standard(_ formatter: NumberFormatter) -> Lexicon {
5656
Lexicon(signs: .standard(formatter), digits: .standard(formatter), separators: .standard(formatter))
5757
}
5858

59-
/// Requires that formatter.numberStyle == .decimal.
59+
/// Requires that formatter.numberStyle == .none.
6060
@inlinable static func currency(_ formatter: NumberFormatter) -> Lexicon {
6161
Lexicon(signs: .currency(formatter), digits: .currency(formatter), separators: .currency(formatter))
6262
}

Sources/DiffableTextStylesXNumeric/Models/Scheme+Currency.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,26 @@ import Foundation
2121
// MARK: State
2222
//=------------------------------------------------------------------------=
2323

24-
@usableFromInline let label: Label
24+
@usableFromInline let identifier: ID
2525
@usableFromInline let lexicon: Lexicon
26+
@usableFromInline let label: Label
2627
@usableFromInline let defaults: Defaults
27-
@usableFromInline let identifier: ID
2828

2929
//=------------------------------------------------------------------------=
3030
// MARK: Initializers
3131
//=------------------------------------------------------------------------=
3232

3333
@inlinable init(_ identifier: ID) {
3434
let formatter = NumberFormatter()
35-
formatter.numberStyle = .decimal
3635
formatter.locale = identifier.locale
3736
formatter.currencyCode = identifier.code
37+
assert(formatter.numberStyle == .none)
3838
//=--------------------------------------=
3939
// MARK: Instantiate
4040
//=--------------------------------------=
4141
self.identifier = identifier
4242
//=--------------------------------------=
43-
// MARK: Instantiate: Style == Decimal
43+
// MARK: Instantiate: Style == None
4444
//=--------------------------------------=
4545
self.lexicon = .currency(formatter)
4646
self.label = .currency(identifier.locale,

Sources/DiffableTextStylesXNumeric/Models/Scheme+Standard.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@ import Foundation
2323

2424
@usableFromInline let identifier: ID
2525
@usableFromInline let lexicon: Lexicon
26-
26+
2727
//=------------------------------------------------------------------------=
2828
// MARK: Initializers
2929
//=------------------------------------------------------------------------=
3030

3131
@inlinable init(_ identifier: ID) {
3232
let formatter = NumberFormatter()
33-
formatter.numberStyle = .decimal
3433
formatter.locale = identifier.locale
34+
assert(formatter.numberStyle == .none)
3535
//=--------------------------------------=
3636
// MARK: Instantiate
3737
//=--------------------------------------=
3838
self.identifier = identifier
3939
//=--------------------------------------=
40-
// MARK: Instantiate: Style == Decimal
40+
// MARK: Instantiate: Style == None
4141
//=--------------------------------------=
4242
self.lexicon = .standard(formatter)
4343
}

Sources/DiffableTextStylesXNumeric/Number/Digit.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ import Foundation
5050
// MARK: Localization
5151
//=------------------------------------------------------------------------=
5252

53+
/// Requires that formatter.numberStyle == .none.
5354
@inlinable func standard(_ formatter: NumberFormatter) -> Character! {
54-
formatter.string(from: numericValue as NSNumber)!.first
55+
assert(formatter.numberStyle == .none)
56+
return formatter.string(from: numericValue as NSNumber)!.first
5557
}
5658
}

0 commit comments

Comments
 (0)