module BookToolkit
{
"response": { "status": "ok", "version": "13", "label": { "plid": "0", "name": "CampusBooks.com", "website_id": "0", "website_name": "CampusBooks.com" }, "page": { "name": "books", "f": "search", "books": { "page": 1, "limit": 1, "results_returned": 1, "total_pages": 1, "total_results": 1, "book": [ { "isbn10": "0387290958", "isbn13": "9780387290959", "author": "", "binding": "Hardcover", "edition": "2006", "image": { "width": 50, "height": 75, "image": "http:\\/\\/ecx.images-amazon.com\\/images\\/I\\/512-hKSVzuL._SL75_.jpg" }, "msrp": 219, "pages": "308", "publish_date": "2006-02-07", "publisher": "Springer", "rank": 2647173, "rating": 0, "title": "Orthogonal Frequency Division Multiplexing for Wireless Communications (Signals and Communication Technology)" } ] } } }
}
{
"ISBN:9780387290959": { "bib_key": "ISBN:9780387290959", "preview": "restricted", "preview_url": "https://archive.org/details/algebraiccombina2003liye", "info_url": "http://openlibrary.org/books/OL22723183M/Orthogonal_frequency_division_mutiplexing_for_wireless_communications", "details": { "publishers": [ "Springer" ], "pagination": "xii, 306 p. :", "identifiers": { "librarything": [ "6252855" ], "goodreads": [ "1539554" ] }, "lc_classifications": [ "TK" ], "source_records": [ "ia:algebraiccombina2003liye" ], "title": "Orthogonal frequency division mutiplexing for wireless communications", "type": { "key": "/type/edition" }, "number_of_pages": 306, "created": { "type": "/type/datetime", "value": "2008-12-19T12:48:38.432497" }, "languages": [ { "key": "/languages/eng" } ], "isbn_10": [ "0387290958" ], "latest_revision": 4, "publish_country": "us ", "key": "/books/OL22723183M", "last_modified": { "type": "/type/datetime", "value": "2014-07-28T10:19:56.239872" }, "publish_date": "2004", "publish_places": [ "New York, NY" ], "works": [ { "key": "/works/OL16920397W" } ], "ocaid": "algebraiccombina2003liye", "by_statement": "edited by Ye (Geoffrey) Li, Gordon Stüber.", "revision": 4 } }
}
Constants
- VERSION
Public Class Methods
calculate_checksum(isbn)
click to toggle source
# File lib/book_toolkit.rb, line 25 def calculate_checksum(isbn) isbn.gsub!(/[^(\d|X)]/, '') c = 0 if isbn.length <= 10 10.downto(2) {|i| c += isbn[10-i].to_i * i} c %= 11 c = 11 - c c ='X' if c == 10 return c elsif isbn.length <= 13 (1..11).step(2) {|i| c += isbn[i].to_i} c *= 3 (0..11).step(2) {|i| c += isbn[i].to_i} c = (220-c) % 10 return c end end
to_isbn13(isbn)
click to toggle source
# File lib/book_toolkit.rb, line 12 def to_isbn13 isbn case isbn.length when 13 return ISBN.thirteen isbn when 10 return ISBN.thirteen isbn when 12 return "#{isbn}#{BookToolkit.calculate_checksum(isbn)}" when 9 return ISBN.thirteen("#{isbn}#{BookToolkit.calculate_checksum(isbn)}") end end