Class: AcademicBenchmarks::Standards::Publication
- Inherits:
-
Object
- Object
- AcademicBenchmarks::Standards::Publication
- Includes:
- AttrToVals, InstVarsToHash
- Defined in:
- lib/academic_benchmarks/standards/publication.rb
Instance Attribute Summary collapse
-
#acronym ⇒ Object
(also: #code)
Returns the value of attribute acronym.
-
#authorities ⇒ Object
Returns the value of attribute authorities.
-
#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:, descr:, guid:, authorities:, children: []) ⇒ Publication
constructor
A new instance of Publication.
-
#rebranch_children ⇒ Object
Children are standards, so rebranch them so we have the following structure:.
Methods included from InstVarsToHash
Methods included from AttrToVals
Constructor Details
#initialize(acronym:, descr:, guid:, authorities:, children: []) ⇒ Publication
Returns a new instance of Publication.
24 25 26 27 28 29 30 |
# File 'lib/academic_benchmarks/standards/publication.rb', line 24 def initialize(acronym:, descr:, guid:, authorities:, children: []) @acronym = acronym @descr = descr @guid = guid @authorities = attr_to_vals(Authority, ) @children = children end |
Instance Attribute Details
#acronym ⇒ Object Also known as: code
Returns the value of attribute acronym.
10 11 12 |
# File 'lib/academic_benchmarks/standards/publication.rb', line 10 def acronym @acronym end |
#authorities ⇒ Object
Returns the value of attribute authorities.
10 11 12 |
# File 'lib/academic_benchmarks/standards/publication.rb', line 10 def @authorities end |
#children ⇒ Object
Returns the value of attribute children.
10 11 12 |
# File 'lib/academic_benchmarks/standards/publication.rb', line 10 def children @children end |
#descr ⇒ Object Also known as: description
Returns the value of attribute descr.
10 11 12 |
# File 'lib/academic_benchmarks/standards/publication.rb', line 10 def descr @descr end |
#guid ⇒ Object
Returns the value of attribute guid.
10 11 12 |
# File 'lib/academic_benchmarks/standards/publication.rb', line 10 def guid @guid end |
Class Method Details
.from_hash(hash) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/academic_benchmarks/standards/publication.rb', line 15 def self.from_hash(hash) self.new( acronym: hash["acronym"], descr: hash["descr"], guid: hash["guid"], authorities: hash["authorities"] ) end |
Instance Method Details
#rebranch_children ⇒ Object
Children are standards, so rebranch them so we have the following structure:
Publication -> Document -> Section -> Standard
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/academic_benchmarks/standards/publication.rb', line 36 def rebranch_children @seen = Set.new() @guid_to_obj = {} new_children = [] @children.each do |child| doc = reparent(child.document, new_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 |