Class: Olibrary::View
- Inherits:
-
Object
- Object
- Olibrary::View
- Defined in:
- lib/olibrary/view.rb
Instance Attribute Summary collapse
-
#bib_key ⇒ Object
Returns the value of attribute bib_key.
-
#info_url ⇒ Object
Returns the value of attribute info_url.
-
#preview ⇒ Object
Returns the value of attribute preview.
-
#preview_url ⇒ Object
Returns the value of attribute preview_url.
-
#thumbnail_url ⇒ Object
Returns the value of attribute thumbnail_url.
Class Method Summary collapse
- .find(type, key) ⇒ Object
- .find_by_isbn(key) ⇒ Object
- .find_by_lccn(key) ⇒ Object
- .find_by_oclc(key) ⇒ Object
- .find_by_olid(key) ⇒ Object
Instance Attribute Details
#bib_key ⇒ Object
Returns the value of attribute bib_key.
4 5 6 |
# File 'lib/olibrary/view.rb', line 4 def bib_key @bib_key end |
#info_url ⇒ Object
Returns the value of attribute info_url.
5 6 7 |
# File 'lib/olibrary/view.rb', line 5 def info_url @info_url end |
#preview ⇒ Object
Returns the value of attribute preview.
6 7 8 |
# File 'lib/olibrary/view.rb', line 6 def preview @preview end |
#preview_url ⇒ Object
Returns the value of attribute preview_url.
7 8 9 |
# File 'lib/olibrary/view.rb', line 7 def preview_url @preview_url end |
#thumbnail_url ⇒ Object
Returns the value of attribute thumbnail_url.
8 9 10 |
# File 'lib/olibrary/view.rb', line 8 def thumbnail_url @thumbnail_url end |
Class Method Details
.find(type, key) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/olibrary/view.rb', line 26 def self.find(type,key) type_for_uri = URI.encode_www_form_component(type) key_for_uri = URI.encode_www_form_component(key) response = RestClient.get "http://openlibrary.org/api/books" + "?bibkeys=#{type_for_uri}:#{key_for_uri}&format=json&jscmd=viewapi" response_data = JSON.parse(response) view = response_data["#{type}:#{key}"] if view = new .bib_key = view["bib_key"] .info_url = view["info_url"] .preview = view["preview"] .preview_url = view["preview_url"] .thumbnail_url = view["thumbnail_url"] else nil end end |
.find_by_isbn(key) ⇒ Object
10 11 12 |
# File 'lib/olibrary/view.rb', line 10 def self.find_by_isbn(key) find("ISBN",key) end |
.find_by_lccn(key) ⇒ Object
14 15 16 |
# File 'lib/olibrary/view.rb', line 14 def self.find_by_lccn(key) find("LCCN",key) end |
.find_by_oclc(key) ⇒ Object
18 19 20 |
# File 'lib/olibrary/view.rb', line 18 def self.find_by_oclc(key) find("OCLC",key) end |
.find_by_olid(key) ⇒ Object
22 23 24 |
# File 'lib/olibrary/view.rb', line 22 def self.find_by_olid(key) find("OLID",key) end |