lisbn
lisbn copied to clipboard
Lisbn.extract()
This adds a helper method to find valid ISBNs within blocks of text.
Lisbn.extract("Long form text mentioning several ISBNs including 978-0-07-352550-1") #=> ["978-0-07-352550-1"]
I like this a lot, but why not make .extract
an instance method? Since Lisbn
subclasses from String
it seems natural to pass in the string you're working on if you intend to do ISBN-related manipulations on it, then just use different methods if you know it's an ISBN or if you know there are ISBNs embedded in it.
Also, since .extract
's behavior is basically a special case of #scan
, maybe call it #scan_isbns
and allow it to take a block as well?
What do you think? Thanks for the PR!
Good idea. I like this interface better, too.