Class: AcademicBenchmarks::Standards::Standard
- Inherits:
-
Object
- Object
- AcademicBenchmarks::Standards::Standard
- Includes:
- AttrToVals, InstVarsToHash
- Defined in:
- lib/academic_benchmarks/standards/standard.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#disciplines ⇒ Object
Returns the value of attribute disciplines.
-
#document ⇒ Object
Returns the value of attribute document.
- #education_levels ⇒ Object
-
#guid ⇒ Object
Returns the value of attribute guid.
-
#label ⇒ Object
Returns the value of attribute label.
-
#level ⇒ Object
Returns the value of attribute level.
-
#number ⇒ Object
Returns the value of attribute number.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#parent_guid ⇒ Object
Returns the value of attribute parent_guid.
-
#section ⇒ Object
Returns the value of attribute section.
-
#seq ⇒ Object
Returns the value of attribute seq.
-
#statement ⇒ Object
Returns the value of attribute statement.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#stem ⇒ Object
Returns the value of attribute stem.
-
#utilizations ⇒ Object
Returns the value of attribute utilizations.
Instance Method Summary collapse
- #add_child(child) ⇒ Object
- #has_children? ⇒ Boolean
-
#initialize(data) ⇒ Standard
(also: #from_hash)
constructor
Before standards are rebranched in Authority#rebranch_children or Document#rebranch_children, they have the following structure.
- #remove_child(child) ⇒ Object
Methods included from InstVarsToHash
Methods included from AttrToVals
Constructor Details
#initialize(data) ⇒ Standard Also known as: from_hash
Before standards are rebranched in Authority#rebranch_children or Document#rebranch_children, they have the following structure.
Standard |-> Document | |-> Publication | |-> Authority |-> Section
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 30 def initialize(data) attributes = data["attributes"] @guid = attributes["guid"] @education_levels = attr_to_val_or_nil(EducationLevels, attributes, "education_levels") @label = attributes["label"] @level = attributes["level"] @section = attr_to_val_or_nil(Section, attributes, "section") @number = attr_to_val_or_nil(Number, attributes, "number") @status = attributes["status"] @disciplines = attr_to_val_or_nil(Disciplines, attributes, "disciplines") @children = [] @document = attr_to_val_or_nil(Document, attributes, "document") @statement = attr_to_val_or_nil(Statement, attributes, "statement") @utilizations = attr_to_vals(Utilizations, attributes["utilizations"]) @parent_guid = data.dig("relationships", "parent", "data", "id") end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
10 11 12 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 10 def children @children end |
#disciplines ⇒ Object
Returns the value of attribute disciplines.
12 13 14 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 12 def disciplines @disciplines end |
#document ⇒ Object
Returns the value of attribute document.
12 13 14 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 12 def document @document end |
#education_levels ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 68 def education_levels return @education_levels if @education_levels # check to see if one of our parents has education levels. Use that if so p = parent while p return p.education_levels if p.education_levels p = p.parent end nil end |
#guid ⇒ Object
Returns the value of attribute guid.
12 13 14 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 12 def guid @guid end |
#label ⇒ Object
Returns the value of attribute label.
12 13 14 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 12 def label @label end |
#level ⇒ Object
Returns the value of attribute level.
12 13 14 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 12 def level @level end |
#number ⇒ Object
Returns the value of attribute number.
12 13 14 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 12 def number @number end |
#parent ⇒ Object
Returns the value of attribute parent.
12 13 14 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 12 def parent @parent end |
#parent_guid ⇒ Object
Returns the value of attribute parent_guid.
12 13 14 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 12 def parent_guid @parent_guid end |
#section ⇒ Object
Returns the value of attribute section.
12 13 14 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 12 def section @section end |
#seq ⇒ Object
Returns the value of attribute seq.
12 13 14 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 12 def seq @seq end |
#statement ⇒ Object
Returns the value of attribute statement.
12 13 14 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 12 def statement @statement end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
10 11 12 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 10 def status @status end |
#stem ⇒ Object
Returns the value of attribute stem.
12 13 14 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 12 def stem @stem end |
#utilizations ⇒ Object
Returns the value of attribute utilizations.
12 13 14 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 12 def utilizations @utilizations end |
Instance Method Details
#add_child(child) ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 49 def add_child(child) raise StandardError.new("Tried to add self as a child") if self == child unless child.is_a?(Standard) raise ArgumentError.new("Tried to set child that isn't a Standard") end child.parent = self @children.push(child) end |
#has_children? ⇒ Boolean
64 65 66 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 64 def has_children? @children.count > 0 end |
#remove_child(child) ⇒ Object
59 60 61 62 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 59 def remove_child(child) child.parent = nil @children.delete(child) end |