Skip to content

Commit

Permalink
a README
Browse files Browse the repository at this point in the history
  • Loading branch information
clayton committed May 1, 2024
1 parent 9b2e2e7 commit c5ef223
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 28 deletions.
103 changes: 75 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,86 @@
# Fsrs
## About The Project

TODO: Delete this and the text below, and describe your gem
rb-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.

Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/fsrs`. To experiment with that code, run `bin/console` for an interactive prompt.
## Getting Started

## Installation
```
gem install fsrs
```

TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
or

Install the gem and add to the application's Gemfile by executing:

$ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
```
bundle add fsrs
```

## Usage

TODO: Write usage instructions here

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/fsrs. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/fsrs/blob/master/CODE_OF_CONDUCT.md).
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

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

## Code of Conduct

Everyone interacting in the Fsrs project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/fsrs/blob/master/CODE_OF_CONDUCT.md).
Distributed under the MIT License. See `LICENSE` for more information.
Binary file added fsrs-0.9.0.gem
Binary file not shown.

0 comments on commit c5ef223

Please sign in to comment.