Class: Ddr::Models::StructDiv

Inherits:
Object
  • Object
show all
Defined in:
lib/ddr/models/struct_div.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#divsObject

Returns the value of attribute divs.



5
6
7
# File 'lib/ddr/models/struct_div.rb', line 5

def divs
  @divs
end

#fptrsObject

Returns the value of attribute fptrs.



5
6
7
# File 'lib/ddr/models/struct_div.rb', line 5

def fptrs
  @fptrs
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/ddr/models/struct_div.rb', line 5

def id
  @id
end

#labelObject

Returns the value of attribute label.



5
6
7
# File 'lib/ddr/models/struct_div.rb', line 5

def label
  @label
end

#orderObject

Returns the value of attribute order.



5
6
7
# File 'lib/ddr/models/struct_div.rb', line 5

def order
  @order
end

#orderlabelObject

Returns the value of attribute orderlabel.



5
6
7
# File 'lib/ddr/models/struct_div.rb', line 5

def orderlabel
  @orderlabel
end

#typeObject

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(options={})
  super.compact
end

#docsObject



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

#objectsObject



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

#pidsObject



21
22
23
# File 'lib/ddr/models/struct_div.rb', line 21

def pids
  collect_pids(self)
end