Class: OpenBD::Resource
- Inherits:
-
Object
- Object
- OpenBD::Resource
- Defined in:
- lib/open_bd/resource.rb
Instance Attribute Summary collapse
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #contents ⇒ Object
- #contents_detail ⇒ Object
- #contributors ⇒ Object
- #cover_image ⇒ Object
- #height ⇒ Object
-
#initialize(source) ⇒ Resource
constructor
A new instance of Resource.
- #isbn ⇒ Object
- #main_title ⇒ Object
- #paper_size ⇒ Object
- #paper_size_detail ⇒ Object
- #publisher ⇒ Object
- #release_date ⇒ Object
- #sub_title ⇒ Object
- #table_of_contents ⇒ Object
- #title ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(source) ⇒ Resource
Returns a new instance of Resource.
5 6 7 |
# File 'lib/open_bd/resource.rb', line 5 def initialize(source) @source = source end |
Instance Attribute Details
#source ⇒ Object (readonly)
Returns the value of attribute source.
3 4 5 |
# File 'lib/open_bd/resource.rb', line 3 def source @source end |
Instance Method Details
#contents ⇒ Object
9 10 11 12 13 |
# File 'lib/open_bd/resource.rb', line 9 def contents if !contents_source.nil? Contents.new(contents_source).contents end end |
#contents_detail ⇒ Object
15 16 17 18 19 |
# File 'lib/open_bd/resource.rb', line 15 def contents_detail if !contents_source.nil? Contents.new(contents_source).contents_detail end end |
#contributors ⇒ Object
21 22 23 24 25 26 |
# File 'lib/open_bd/resource.rb', line 21 def contributors values = source.dig("onix", "DescriptiveDetail", "Contributor") if !values.nil? values.map { |v| Contributor.new(v) } end end |
#cover_image ⇒ Object
28 29 30 |
# File 'lib/open_bd/resource.rb', line 28 def cover_image source.dig("summary", "cover") end |
#height ⇒ Object
32 33 34 |
# File 'lib/open_bd/resource.rb', line 32 def height Paper.new(source.dig("onix", "DescriptiveDetail")).height end |
#isbn ⇒ Object
36 37 38 |
# File 'lib/open_bd/resource.rb', line 36 def isbn source.dig("summary", "isbn") end |
#main_title ⇒ Object
40 41 42 |
# File 'lib/open_bd/resource.rb', line 40 def main_title Title.new(source.dig("onix", "DescriptiveDetail")).main_title end |
#paper_size ⇒ Object
44 45 46 |
# File 'lib/open_bd/resource.rb', line 44 def paper_size Paper.new(source.dig("onix", "DescriptiveDetail")).size end |
#paper_size_detail ⇒ Object
48 49 50 |
# File 'lib/open_bd/resource.rb', line 48 def paper_size_detail Paper.new(source.dig("onix", "DescriptiveDetail")).size_detail end |
#publisher ⇒ Object
52 53 54 |
# File 'lib/open_bd/resource.rb', line 52 def publisher source.dig("summary", "publisher") end |
#release_date ⇒ Object
56 57 58 |
# File 'lib/open_bd/resource.rb', line 56 def release_date source.dig("summary", "pubdate") end |
#sub_title ⇒ Object
60 61 62 |
# File 'lib/open_bd/resource.rb', line 60 def sub_title Title.new(source.dig("onix", "DescriptiveDetail")).sub_title end |
#table_of_contents ⇒ Object
64 65 66 67 68 |
# File 'lib/open_bd/resource.rb', line 64 def table_of_contents if !contents_source.nil? Contents.new(contents_source).table_of_contents end end |