Class: Abebooks4r::Abe

Inherits:
Object
  • Object
show all
Defined in:
lib/abebooks4r.rb

Defined Under Namespace

Classes: Response

Constant Summary collapse

@@options =
{:clientkey => ''}
@@debug =
false

Class Method Summary collapse

Class Method Details

.configure {|@@options| ... } ⇒ Object

Yields:

Raises:

  • (ArgumentError)


59
60
61
62
# File 'lib/abebooks4r.rb', line 59

def self.configure(&proc)
  raise ArgumentError, "Block is required." unless block_given?
  yield @@options
end

.debugObject

Get debug flag.



50
51
52
# File 'lib/abebooks4r.rb', line 50

def self.debug
  @@debug
end

.debug=(dbg) ⇒ Object

Set debug flag to true or false.



55
56
57
# File 'lib/abebooks4r.rb', line 55

def self.debug=(dbg)
  @@debug = dbg
end

.optionsObject

Default service options



40
41
42
# File 'lib/abebooks4r.rb', line 40

def self.options
  @@options
end

.options=(opts) ⇒ Object

Set default service options



45
46
47
# File 'lib/abebooks4r.rb', line 45

def self.options=(opts)
  @@options = opts
end

.search(params = {}) ⇒ Object

search abe books web service for the book



65
66
67
68
69
70
71
72
73
74
# File 'lib/abebooks4r.rb', line 65

def self.search(params = {})
  url = self.prepare_url(params)
  log "Request URL: #{url}"
  res = Net::HTTP.get_response(url)
  unless res.kind_of? Net::HTTPSuccess
    raise Abebooks4r::RequestError, "HTTP Response: #{res.code} #{res.message}"
  end
  log "Response text: #{res.body}"
  Response.new(res.body)
end