Class: Olibrary::Data
- Inherits:
-
Object
- Object
- Olibrary::Data
- Defined in:
- lib/olibrary/data.rb
Instance Attribute Summary collapse
-
#authors ⇒ Object
Returns the value of attribute authors.
-
#classifications ⇒ Object
Returns the value of attribute classifications.
-
#cover ⇒ Object
Returns the value of attribute cover.
-
#ebooks ⇒ Object
Returns the value of attribute ebooks.
-
#excerpts ⇒ Object
Returns the value of attribute excerpts.
-
#identifiers ⇒ Object
Returns the value of attribute identifiers.
-
#links ⇒ Object
Returns the value of attribute links.
-
#pages ⇒ Object
Returns the value of attribute pages.
-
#publish_date ⇒ Object
Returns the value of attribute publish_date.
-
#publish_places ⇒ Object
Returns the value of attribute publish_places.
-
#publishers ⇒ Object
Returns the value of attribute publishers.
-
#subject_people ⇒ Object
Returns the value of attribute subject_people.
-
#subject_places ⇒ Object
Returns the value of attribute subject_places.
-
#subject_times ⇒ Object
Returns the value of attribute subject_times.
-
#subjects ⇒ Object
Returns the value of attribute subjects.
-
#subtitle ⇒ Object
Returns the value of attribute subtitle.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
-
#weight ⇒ Object
Returns the value of attribute weight.
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
#authors ⇒ Object
Returns the value of attribute authors.
7 8 9 |
# File 'lib/olibrary/data.rb', line 7 def @authors end |
#classifications ⇒ Object
Returns the value of attribute classifications.
9 10 11 |
# File 'lib/olibrary/data.rb', line 9 def classifications @classifications end |
#cover ⇒ Object
Returns the value of attribute cover.
15 16 17 |
# File 'lib/olibrary/data.rb', line 15 def cover @cover end |
#ebooks ⇒ Object
Returns the value of attribute ebooks.
16 17 18 |
# File 'lib/olibrary/data.rb', line 16 def ebooks @ebooks end |
#excerpts ⇒ Object
Returns the value of attribute excerpts.
13 14 15 |
# File 'lib/olibrary/data.rb', line 13 def excerpts @excerpts end |
#identifiers ⇒ Object
Returns the value of attribute identifiers.
8 9 10 |
# File 'lib/olibrary/data.rb', line 8 def identifiers @identifiers end |
#links ⇒ Object
Returns the value of attribute links.
14 15 16 |
# File 'lib/olibrary/data.rb', line 14 def links @links end |
#pages ⇒ Object
Returns the value of attribute pages.
17 18 19 |
# File 'lib/olibrary/data.rb', line 17 def pages @pages end |
#publish_date ⇒ Object
Returns the value of attribute publish_date.
12 13 14 |
# File 'lib/olibrary/data.rb', line 12 def publish_date @publish_date end |
#publish_places ⇒ Object
Returns the value of attribute publish_places.
11 12 13 |
# File 'lib/olibrary/data.rb', line 11 def publish_places @publish_places end |
#publishers ⇒ Object
Returns the value of attribute publishers.
11 12 13 |
# File 'lib/olibrary/data.rb', line 11 def publishers @publishers end |
#subject_people ⇒ Object
Returns the value of attribute subject_people.
10 11 12 |
# File 'lib/olibrary/data.rb', line 10 def subject_people @subject_people end |
#subject_places ⇒ Object
Returns the value of attribute subject_places.
10 11 12 |
# File 'lib/olibrary/data.rb', line 10 def subject_places @subject_places end |
#subject_times ⇒ Object
Returns the value of attribute subject_times.
10 11 12 |
# File 'lib/olibrary/data.rb', line 10 def subject_times @subject_times end |
#subjects ⇒ Object
Returns the value of attribute subjects.
10 11 12 |
# File 'lib/olibrary/data.rb', line 10 def subjects @subjects end |
#subtitle ⇒ Object
Returns the value of attribute subtitle.
6 7 8 |
# File 'lib/olibrary/data.rb', line 6 def subtitle @subtitle end |
#title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'lib/olibrary/data.rb', line 5 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/olibrary/data.rb', line 4 def url @url end |
#weight ⇒ Object
Returns the value of attribute weight.
18 19 20 |
# File 'lib/olibrary/data.rb', line 18 def weight @weight end |
Class Method Details
.find(type, key) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/olibrary/data.rb', line 36 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=data" response_data = JSON.parse(response) book = response_data["#{type}:#{key}"] if book = new .title = book["title"] .subtitle = book["subtitle"] . = book["authors"] .identifiers = book["identifiers"] .classifications = book["classifications"] .subjects = book["subjects"] .subject_places = book["subject_places"] .subject_people = book["subject_people"] .subject_times = book["subject_times"] .publishers = book["publishers"] .publish_places = book["publish_places"] .publish_date = book["publish_date"] .excerpts = book["excerpts"] .links = book["links"] .cover = book["cover"] .ebooks = book["ebooks"] .pages = book["number_of_pages"] .weight = book["weight"] else nil end end |
.find_by_isbn(key) ⇒ Object
20 21 22 |
# File 'lib/olibrary/data.rb', line 20 def self.find_by_isbn(key) find("ISBN",key) end |
.find_by_lccn(key) ⇒ Object
24 25 26 |
# File 'lib/olibrary/data.rb', line 24 def self.find_by_lccn(key) find("LCCN",key) end |
.find_by_oclc(key) ⇒ Object
28 29 30 |
# File 'lib/olibrary/data.rb', line 28 def self.find_by_oclc(key) find("OCLC",key) end |
.find_by_olid(key) ⇒ Object
32 33 34 |
# File 'lib/olibrary/data.rb', line 32 def self.find_by_olid(key) find("OLID",key) end |