Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: access level #19

Merged
merged 2 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Sources/FSRS/Algorithm/FSRS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public class FSRS: FSRSAlgorithm {
* const recordLogItem = f.repeat(card, new Date(), Rating.Again, nextAfterHandler);
* ```
*/
func next(
public func next(
card: Card,
now: Date,
grade: Rating,
Expand Down Expand Up @@ -220,7 +220,7 @@ public class FSRS: FSRSAlgorithm {
* const rollbackFromAfterHandler = f.rollback(card, log, cardAfterHandler);
* ```
*/
func rollback(
public func rollback(
card: Card,
log: ReviewLog,
completion: ((Card) -> Card)? = nil
Expand Down Expand Up @@ -319,7 +319,7 @@ public class FSRS: FSRSAlgorithm {
* const forgetFromAfterHandler = f.forget(card, date_scheduler(now, 1, true), false, forgetAfterHandler);
* ```
*/
func forget(
public func forget(
card: Card,
now: Date,
resetCount: Bool = false,
Expand Down Expand Up @@ -394,7 +394,7 @@ public class FSRS: FSRSAlgorithm {
console.log(results_short)
* ```
*/
func reschedule(
public func reschedule(
currentCard: Card,
reviews: [ReviewLog],
options: RescheduleOptions
Expand Down
51 changes: 28 additions & 23 deletions Sources/FSRS/Models/FSRSModels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public enum CardState: Int, Codable {
public enum Rating: Int, Codable, Equatable, CaseIterable {
case manual = 0, again = 1, hard, good, easy

var stringValue: String {
public var stringValue: String {
switch self {
case .manual: return "manual"
case .again: return "again"
Expand All @@ -36,16 +36,16 @@ public enum Rating: Int, Codable, Equatable, CaseIterable {
}
}

public struct ReviewLog: Equatable, Codable {
var rating: Rating // Rating of the review (Again, Hard, Good, Easy)
var state: CardState? // State of the review (New, Learning, Review, Relearning)
var due: Date? // Date of the last scheduling
var stability: Double? // Memory stability during the review
var difficulty: Double? // Difficulty of the card during the review
var elapsedDays: Double // Number of days elapsed since the last review
var lastElapsedDays: Double // Number of days between the last two reviews
var scheduledDays: Double // Number of days until the next review
var review: Date // Date of the review
public struct ReviewLog: Equatable, Codable, Hashable {
public var rating: Rating // Rating of the review (Again, Hard, Good, Easy)
public var state: CardState? // State of the review (New, Learning, Review, Relearning)
public var due: Date? // Date of the last scheduling
public var stability: Double? // Memory stability during the review
public var difficulty: Double? // Difficulty of the card during the review
public var elapsedDays: Double // Number of days elapsed since the last review
public var lastElapsedDays: Double // Number of days between the last two reviews
public var scheduledDays: Double // Number of days until the next review
public var review: Date // Date of the review

public init(
rating: Rating,
Expand All @@ -69,7 +69,7 @@ public struct ReviewLog: Equatable, Codable {
self.review = review
}

var newLog: ReviewLog {
public var newLog: ReviewLog {
ReviewLog(
rating: rating,
state: state,
Expand All @@ -84,7 +84,7 @@ public struct ReviewLog: Equatable, Codable {
}
}

public struct Card: Equatable, Codable {
public struct Card: Equatable, Codable, Hashable {
public var due: Date // Date when the card is next due for review
public var stability: Double // A measure of how well the information is retained
public var difficulty: Double // Reflects the inherent difficulty of the card content
Expand Down Expand Up @@ -117,7 +117,7 @@ public struct Card: Equatable, Codable {
self.lastReview = lastReview
}

var newCard: Card {
public var newCard: Card {
Card(
due: due,
stability: stability,
Expand All @@ -143,19 +143,24 @@ public struct Card: Equatable, Codable {
}
}

public struct RecordLogItem: Codable, Equatable {
public struct RecordLogItem: Codable, Equatable, Hashable {
public var card: Card
var log: ReviewLog
public var log: ReviewLog

public init(card: Card, log: ReviewLog) {
self.card = card
self.log = log
}
}

public typealias RecordLog = [Rating: RecordLogItem]

public struct FSRSParameters: Codable, Equatable {
var requestRetention: Double
var maximumInterval: Double
var w: [Double]
var enableFuzz: Bool
var enableShortTerm: Bool
public var requestRetention: Double
public var maximumInterval: Double
public var w: [Double]
public var enableFuzz: Bool
public var enableShortTerm: Bool

public init(
requestRetention: Double? = nil,
Expand All @@ -178,11 +183,11 @@ public struct FSRSReview: Codable {
* 0-4: Manual, Again, Hard, Good, Easy
* = revlog.rating
*/
var rating: Rating
public var rating: Rating
/**
* The number of days that passed
* = revlog.elapsed_days
* = round(revlog[-1].review - revlog[-2].review)
*/
var deltaT: Double
public var deltaT: Double
}
Loading