Class: Ddr::Models::StructDiv
- Inherits:
-
Object
- Object
- Ddr::Models::StructDiv
- Defined in:
- lib/ddr/models/struct_div.rb
Instance Attribute Summary collapse
-
#divs ⇒ Object
Returns the value of attribute divs.
-
#fptrs ⇒ Object
Returns the value of attribute fptrs.
-
#id ⇒ Object
Returns the value of attribute id.
-
#label ⇒ Object
Returns the value of attribute label.
-
#order ⇒ Object
Returns the value of attribute order.
-
#orderlabel ⇒ Object
Returns the value of attribute orderlabel.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #as_json(options = {}) ⇒ Object
- #docs ⇒ Object
-
#initialize(structmap_or_div_node) ⇒ StructDiv
constructor
A new instance of StructDiv.
- #objects ⇒ Object
- #pids ⇒ Object
Constructor Details
#initialize(structmap_or_div_node) ⇒ StructDiv
Returns a new instance of StructDiv.
7 8 9 10 11 12 13 14 15 |
# File 'lib/ddr/models/struct_div.rb', line 7 def initialize(structmap_or_div_node) @id = structmap_or_div_node['ID'] @label = structmap_or_div_node['LABEL'] @order = structmap_or_div_node['ORDER'] @orderlabel = structmap_or_div_node['ORDERLABEL'] @type = structmap_or_div_node['TYPE'] @fptrs = fptr_pids(structmap_or_div_node) if structmap_or_div_node.node_name == "div" @divs = subdivs(structmap_or_div_node).sort end |
Instance Attribute Details
#divs ⇒ Object
Returns the value of attribute divs.
5 6 7 |
# File 'lib/ddr/models/struct_div.rb', line 5 def divs @divs end |
#fptrs ⇒ Object
Returns the value of attribute fptrs.
5 6 7 |
# File 'lib/ddr/models/struct_div.rb', line 5 def fptrs @fptrs end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/ddr/models/struct_div.rb', line 5 def id @id end |
#label ⇒ Object
Returns the value of attribute label.
5 6 7 |
# File 'lib/ddr/models/struct_div.rb', line 5 def label @label end |
#order ⇒ Object
Returns the value of attribute order.
5 6 7 |
# File 'lib/ddr/models/struct_div.rb', line 5 def order @order end |
#orderlabel ⇒ Object
Returns the value of attribute orderlabel.
5 6 7 |
# File 'lib/ddr/models/struct_div.rb', line 5 def orderlabel @orderlabel end |
#type ⇒ Object
Returns the value of attribute type.
5 6 7 |
# File 'lib/ddr/models/struct_div.rb', line 5 def type @type end |
Instance Method Details
#<=>(other) ⇒ Object
17 18 19 |
# File 'lib/ddr/models/struct_div.rb', line 17 def <=>(other) self.order.to_i <=> other.order.to_i end |
#as_json(options = {}) ⇒ Object
39 40 41 |
# File 'lib/ddr/models/struct_div.rb', line 39 def as_json(={}) super.compact end |
#docs ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/ddr/models/struct_div.rb', line 25 def docs query = ActiveFedora::SolrQueryBuilder.construct_query_for_ids(pids) results = ActiveFedora::SolrService.query(query, rows: 999999) results.each_with_object({}) do |r, memo| memo[r["id"]] = ::SolrDocument.new(r) end end |
#objects ⇒ Object
33 34 35 36 37 |
# File 'lib/ddr/models/struct_div.rb', line 33 def objects pids.each_with_object({}) do |pid, memo| memo[pid] = ActiveFedora::Base.find(pid) end end |
#pids ⇒ Object
21 22 23 |
# File 'lib/ddr/models/struct_div.rb', line 21 def pids collect_pids(self) end |