mirror of
https://github.com/dkam/openlib.git
synced 2025-12-28 19:24:53 +00:00
Add a to_h method
This commit is contained in:
@@ -43,6 +43,15 @@ module Openlib
|
|||||||
authors
|
authors
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_h
|
||||||
|
%i[url authors identifiers classifications subjects
|
||||||
|
subject_places subject_people subject_times publishers
|
||||||
|
publish_places publish_date excerpts links cover ebooks
|
||||||
|
number_of_pages weight title].each_with_object({}) do |obj, memo|
|
||||||
|
memo[obj] = send(obj) unless send(obj).nil?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def method_missing(m, *args, &block)
|
def method_missing(m, *args, &block)
|
||||||
case m
|
case m
|
||||||
when :info_url, :preview, :preview_url, :thumbnail_url
|
when :info_url, :preview, :preview_url, :thumbnail_url
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
module Openlib
|
module Openlib
|
||||||
VERSION = "0.1.0"
|
VERSION = "0.1.1"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user