Class: CONTENTdmAPI::Item
- Inherits:
-
Object
- Object
- CONTENTdmAPI::Item
- Defined in:
- lib/contentdm_api/item.rb
Overview
A convenience method to retrive a Ruby hash of Item data from the CONTENTdm API along with an optional call to fetch Compound Object Info
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#requester ⇒ Object
readonly
Returns the value of attribute requester.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#with_compound ⇒ Object
readonly
Returns the value of attribute with_compound.
Instance Method Summary collapse
- #compounds_to_h ⇒ Object
-
#initialize(base_url: '', collection: '', id: 0, with_compound: true, requester: RequestBatch, response: Response) ⇒ Void
constructor
compound?.
-
#metadata ⇒ Hash
A hash of item metadata with optional compound data for the given item.
Constructor Details
#initialize(base_url: '', collection: '', id: 0, with_compound: true, requester: RequestBatch, response: Response) ⇒ Void
compound?
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/contentdm_api/item.rb', line 25 def initialize(base_url: '', collection: '', id: 0, with_compound: true, requester: RequestBatch, response: Response) @collection = collection @id = id @with_compound = with_compound @requester = requester @base_url = base_url @response = response end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
5 6 7 |
# File 'lib/contentdm_api/item.rb', line 5 def base_url @base_url end |
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
5 6 7 |
# File 'lib/contentdm_api/item.rb', line 5 def collection @collection end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/contentdm_api/item.rb', line 5 def id @id end |
#requester ⇒ Object (readonly)
Returns the value of attribute requester.
5 6 7 |
# File 'lib/contentdm_api/item.rb', line 5 def requester @requester end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
5 6 7 |
# File 'lib/contentdm_api/item.rb', line 5 def response @response end |
#with_compound ⇒ Object (readonly)
Returns the value of attribute with_compound.
5 6 7 |
# File 'lib/contentdm_api/item.rb', line 5 def with_compound @with_compound end |
Instance Method Details
#compounds_to_h ⇒ Object
51 52 53 54 55 |
# File 'lib/contentdm_api/item.rb', line 51 def compounds_to_h [page].flatten.map do |compound| block_given? ? yield(compound(compound)) : compound(compound) end end |
#metadata ⇒ Hash
A hash of item metadata with optional compound data for the given item
dmGetCompoundObjectInfo functions
43 44 45 46 47 48 49 |
# File 'lib/contentdm_api/item.rb', line 43 def if with_compound result_with_id.merge('page' => compounds_to_h) else result_with_id.merge('page' => []) end end |