Class: AcademicBenchmarks::Standards::Authority
- Inherits:
-
Object
- Object
- AcademicBenchmarks::Standards::Authority
- Includes:
- InstVarsToHash
- Defined in:
- lib/academic_benchmarks/standards/authority.rb
Instance Attribute Summary collapse
-
#acronym ⇒ Object
(also: #code)
Returns the value of attribute acronym.
-
#children ⇒ Object
Returns the value of attribute children.
-
#descr ⇒ Object
(also: #description)
Returns the value of attribute descr.
-
#guid ⇒ Object
Returns the value of attribute guid.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(acronym:, guid:, descr:, children: []) ⇒ Authority
constructor
A new instance of Authority.
-
#rebranch_children ⇒ Object
Children are standards, so rebranch them so we have the following structure:.
Methods included from InstVarsToHash
Constructor Details
#initialize(acronym:, guid:, descr:, children: []) ⇒ Authority
Returns a new instance of Authority.
21 22 23 24 25 26 |
# File 'lib/academic_benchmarks/standards/authority.rb', line 21 def initialize(acronym:, guid:, descr:, children: []) @acronym = acronym @guid = guid @descr = descr @children = children end |
Instance Attribute Details
#acronym ⇒ Object Also known as: code
Returns the value of attribute acronym.
8 9 10 |
# File 'lib/academic_benchmarks/standards/authority.rb', line 8 def acronym @acronym end |
#children ⇒ Object
Returns the value of attribute children.
8 9 10 |
# File 'lib/academic_benchmarks/standards/authority.rb', line 8 def children @children end |
#descr ⇒ Object Also known as: description
Returns the value of attribute descr.
8 9 10 |
# File 'lib/academic_benchmarks/standards/authority.rb', line 8 def descr @descr end |
#guid ⇒ Object
Returns the value of attribute guid.
8 9 10 |
# File 'lib/academic_benchmarks/standards/authority.rb', line 8 def guid @guid end |
Class Method Details
.from_hash(hash) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/academic_benchmarks/standards/authority.rb', line 13 def self.from_hash(hash) self.new( acronym: hash["acronym"], guid: hash["guid"], descr: hash["descr"] ) end |
Instance Method Details
#rebranch_children ⇒ Object
Children are standards, so rebranch them so we have the following structure:
Authority -> Publication -> Document -> Section -> Standard
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/academic_benchmarks/standards/authority.rb', line 32 def rebranch_children @seen = Set.new() @guid_to_obj = {} new_children = [] @children.each do |child| pub = reparent(child.document.publication, new_children) doc = reparent(child.document, pub.children) sec = reparent(child.section, doc.children) sec.children.push(child) end @children.replace(new_children) remove_instance_variable('@seen') remove_instance_variable('@guid_to_obj') end |