lisbn icon indicating copy to clipboard operation
lisbn copied to clipboard

Lisbn.extract()

Open jelder opened this issue 11 years ago • 2 comments

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"]

jelder avatar Oct 18 '13 17:10 jelder

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!

ragalie avatar Oct 18 '13 19:10 ragalie

Good idea. I like this interface better, too.

jelder avatar Oct 21 '13 16:10 jelder