https://github.com/open-spaced-repetition/rb-fsrs
A ruby implementation of the Open Spaced Repetition's Free Spaced Repetition Scheduler
https://github.com/open-spaced-repetition/rb-fsrs
Last synced: 16 days ago
JSON representation
A ruby implementation of the Open Spaced Repetition's Free Spaced Repetition Scheduler
- Host: GitHub
- URL: https://github.com/open-spaced-repetition/rb-fsrs
- Owner: open-spaced-repetition
- License: mit
- Created: 2024-05-01T00:11:46.000Z (12 months ago)
- Default Branch: master
- Last Pushed: 2025-02-05T04:49:08.000Z (2 months ago)
- Last Synced: 2025-02-05T05:26:37.368Z (2 months ago)
- Language: Ruby
- Size: 33.2 KB
- Stars: 7
- Watchers: 1
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-fsrs - rb-fsrs
README
[](https://github.com/clayton/rb-fsrs/actions/workflows/main.yml)
[](https://badge.fury.io/rb/fsrs)
## About The Projectrb-fsrs is a Ruby Gem implements [Free Spaced Repetition Scheduler algorithm](https://github.com/open-spaced-repetition/free-spaced-repetition-scheduler). It helps developers apply FSRS in their flashcard apps.
## Getting Started
```
gem install fsrs
```or
```
bundle add fsrs
```## Usage
Create a card and review it at a given time:
```ruby
require 'fsrs'scheduler = Fsrs::Scheduler.new
card = Fsrs::Card.new
now = DateTime.now.utc
scheduling_cards = scheduler.repeat(card, now)
```There are four ratings:
```ruby
Rating::AGAIN # forget; incorrect response
Rating::HARD # recall; correct response recalled with serious difficulty
Rating::GOOD # recall; correct response after a hesitation
Rating::EASY # recall; perfect response
```Get the new state of card for each rating:
```ruby
scheduling_cards[Rating::AGAIN].card
scheduling_cards[Rating::HARD].card
scheduling_cards[Rating::GOOD].card
scheduling_cards[Rating::EASY].card
```Get the scheduled days for each rating:
```ruby
card_again.scheduled_days
card_hard.scheduled_days
card_good.scheduled_days
card_easy.scheduled_days
```Update the card after rating `GOOD`:
```ruby
card = scheduling_cards[Rating::GOOD].card
```Get the review log after rating `GOOD`:
```ruby
review_log = scheduling_cards[Rating::GOOD].review_log
```Get the due date for card:
```ruby
due = card.due
```There are four states:
```ruby
State::NEW # Never been studied
State::LEARNING # Been studied for the first time recently
State::REVIEW # Graduate from learning state
State::RELEARNING # Forgotten in review state
```## Acknowledgements
* [Open Spaced Repetition](https://github.com/open-spaced-repetition)
* [py-fsrs](https://github.com/open-spaced-repetition/py-fsrs)This library was ported from [py-fsrs](https://github.com/open-spaced-repetition/py-fsrs) to Ruby. Much refactoring to be done, but the core logic is the same.
## License
Distributed under the MIT License. See `LICENSE` for more information.