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

Version Path
umlaut-3.0.0beta4 lib/service_adaptors/book_finder.rb
umlaut-3.0.0beta3 lib/service_adaptors/book_finder.rb
umlaut-3.0.0beta2 lib/service_adaptors/book_finder.rb
umlaut-3.0.0beta1 lib/service_adaptors/book_finder.rb
umlaut-3.0.0alpha15 lib/service_adaptors/book_finder.rb
umlaut-3.0.0alpha14 lib/service_adaptors/book_finder.rb
umlaut-3.0.0alpha13 lib/service_adaptors/book_finder.rb
umlaut-3.0.0alpha12 lib/service_adaptors/book_finder.rb
umlaut-3.0.0alpha11 lib/service_adaptors/book_finder.rb
umlaut-3.0.0alpha10 lib/service_adaptors/book_finder.rb
umlaut-3.0.0alpha9 lib/service_adaptors/book_finder.rb
umlaut-3.0.0alpha8 lib/service_adaptors/book_finder.rb
umlaut-3.0.0alpha7 lib/service_adaptors/book_finder.rb
umlaut-3.0.0alpha6 lib/service_adaptors/book_finder.rb
umlaut-3.0.0alpha5 lib/service_adaptors/book_finder.rb
umlaut-3.0.0alpha4 lib/service_adaptors/book_finder.rb
umlaut-3.0.0alpha3 lib/service_adaptors/book_finder.rb
umlaut-3.0.0alpha2 lib/service_adaptors/book_finder.rb
umlaut-3.0.0alpha1 lib/service_adaptors/book_finder.rb