Sha256: 9217f1428dade0236e1a35f4973bb69bfac3ac2cd850e338ed276356abc51ad4
Contents?: true
Size: 1.05 KB
Versions: 59
Compression:
Stored size: 1.05 KB
Contents
# Link to BookFinder.com to compare online new and used prices for a book. # Requires an ISBN. # Does not a pre-check, just generates the link blind, but I think almost any # ISBN will get results on BookFinder. class BookFinder < Service require 'isbn' def initialize(config) @display_text = "Compare online prices" @display_name = "BookFinder.com" # %s is where the ISBN goes @url_template = 'http://www.bookfinder.com/search/?isbn=%s&st=xl&ac=qr' super(config) end def service_types_generated return [ServiceTypeValue['highlighted_link']] end def handle(umlaut_request) isbn = umlaut_request.referent.isbn # Unless we have a valid isbn, give up return request.dispatched(self, true) unless isbn && ISBN.valid?(isbn) # Okay, make a link url = @url_template.sub('%s', isbn) umlaut_request.add_service_response( :service=>self, :url=> url, :display_text=> @display_text, :service_type_value => :highlighted_link ) return request.dispatched(self, true) end end
Version data entries
59 entries across 59 versions & 1 rubygems