A Ruby cloze deletion module
GitHub: bchase/cloze
Add this line to your application's Gemfile:
gem 'cloze', :git => 'git://github.com/bchase/cloze.git'
And then execute:
$ bundle
Simply include Cloze::Deletion
in String
or a String
subclass
class String
include Cloze::Deletion
end
and then use the .cloze_delete
instance method to perform cloze deletions
"foo".cloze_delete(:each)
# => ['#oo','f#o','fo#']
"foo".cloze_delete(:each, :all)
# => ['#oo','f#o','fo#','###']
"巻き込む".cloze_delete(:kanji)
# => ['#き込む','巻き#む']
# using a different cloze deletion character...
"foo".cloze_delete(:each, with: '?')
# => ['?oo','f?o','fo?']
.cloze_delete
will default to :each
if no arguments are supplied
"foo".cloze_delete
# => ['#oo','f#o','fo#']
and it can also be used simply as .cloze
"foo".cloze
# => ['#oo','f#o','fo#']
It's also possible to permanently change the cloze deletion character:
Cloze::Deletion.default_deletion_character = '?'
"foo".cloze_delete(:each)
# => ['?oo','f?o','fo?']
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Write specs
- Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request