Class: AcademicBenchmarks::Standards::Standard
- Inherits:
-
Object
- Object
- AcademicBenchmarks::Standards::Standard
- Includes:
- InstVarsToHash
- Defined in:
- lib/academic_benchmarks/standards/standard.rb
Instance Attribute Summary collapse
-
#adopt_year ⇒ Object
Returns the value of attribute adopt_year.
-
#authority ⇒ Object
Returns the value of attribute authority.
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#course ⇒ Object
Returns the value of attribute course.
-
#deepest ⇒ Object
Returns the value of attribute deepest.
-
#description ⇒ Object
(also: #descr)
Returns the value of attribute description.
-
#document ⇒ Object
Returns the value of attribute document.
-
#grade ⇒ Object
Returns the value of attribute grade.
-
#guid ⇒ Object
Returns the value of attribute guid.
-
#has_relations ⇒ Object
Returns the value of attribute has_relations.
-
#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.
-
#seq ⇒ Object
Returns the value of attribute seq.
-
#status ⇒ Object
Returns the value of attribute status.
-
#stem ⇒ Object
Returns the value of attribute stem.
-
#subject ⇒ Object
Returns the value of attribute subject.
-
#subject_doc ⇒ Object
Returns the value of attribute subject_doc.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #add_child(child) ⇒ Object
- #deepest? ⇒ Boolean
- #has_children? ⇒ Boolean
-
#initialize(data) ⇒ Standard
constructor
A new instance of Standard.
- #obsolete? ⇒ Boolean
- #remove_child(child) ⇒ Object
Methods included from InstVarsToHash
Constructor Details
#initialize(data) ⇒ Standard
Returns a new instance of Standard.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 16 def initialize(data) data = data["data"] if data["data"] @guid = data["guid"] @grade = attr_to_val_or_nil(Grade, data, "grade") @label = data["label"] @level = data["level"] @course = attr_to_val_or_nil(Course, data, "course") @number = data["number"] @status = data["status"] @parent = nil @subject = attr_to_val_or_nil(Subject, data, "subject") @deepest = data["deepest"] @version = data["version"] @children = [] @document = attr_to_val_or_nil(Document, data, "document") @authority = attr_to_val_or_nil(Authority, data, "authority") @adopt_year = data["adopt_year"] @description = data["descr"] @subject_doc = attr_to_val_or_nil(SubjectDoc, data, "subject_doc") @has_relations = attr_to_val_or_nil(HasRelations, data, "has_relations") # Parent guid extraction can be a little more complicated. Thanks AB! if data["parent"] && data["parent"].is_a?(String) @parent_guid = data["parent"] elsif data["parent"] && data["parent"].is_a?(Hash) @parent_guid = data["parent"]["guid"] end end |
Instance Attribute Details
#adopt_year ⇒ Object
Returns the value of attribute adopt_year.
9 10 11 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 9 def adopt_year @adopt_year end |
#authority ⇒ Object
Returns the value of attribute authority.
9 10 11 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 9 def @authority end |
#children ⇒ Object (readonly)
Returns the value of attribute children.
8 9 10 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 8 def children @children end |
#course ⇒ Object
Returns the value of attribute course.
9 10 11 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 9 def course @course end |
#deepest ⇒ Object
Returns the value of attribute deepest.
8 9 10 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 8 def deepest @deepest end |
#description ⇒ Object Also known as: descr
Returns the value of attribute description.
9 10 11 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 9 def description @description end |
#document ⇒ Object
Returns the value of attribute document.
9 10 11 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 9 def document @document end |
#grade ⇒ Object
Returns the value of attribute grade.
9 10 11 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 9 def grade @grade end |
#guid ⇒ Object
Returns the value of attribute guid.
9 10 11 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 9 def guid @guid end |
#has_relations ⇒ Object
Returns the value of attribute has_relations.
9 10 11 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 9 def has_relations @has_relations end |
#label ⇒ Object
Returns the value of attribute label.
9 10 11 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 9 def label @label end |
#level ⇒ Object
Returns the value of attribute level.
9 10 11 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 9 def level @level end |
#number ⇒ Object
Returns the value of attribute number.
9 10 11 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 9 def number @number end |
#parent ⇒ Object
Returns the value of attribute parent.
9 10 11 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 9 def parent @parent end |
#parent_guid ⇒ Object
Returns the value of attribute parent_guid.
9 10 11 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 9 def parent_guid @parent_guid end |
#seq ⇒ Object
Returns the value of attribute seq.
9 10 11 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 9 def seq @seq end |
#status ⇒ Object
Returns the value of attribute status.
8 9 10 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 8 def status @status end |
#stem ⇒ Object
Returns the value of attribute stem.
9 10 11 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 9 def stem @stem end |
#subject ⇒ Object
Returns the value of attribute subject.
9 10 11 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 9 def subject @subject end |
#subject_doc ⇒ Object
Returns the value of attribute subject_doc.
9 10 11 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 9 def subject_doc @subject_doc end |
#version ⇒ Object
Returns the value of attribute version.
9 10 11 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 9 def version @version end |
Instance Method Details
#active? ⇒ Boolean
45 46 47 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 45 def active? status == "Active" end |
#add_child(child) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 73 def add_child(child) unless child.is_a?(Standard) raise ArgumentError.new("Tried to set child that isn't a Standard") end @children.push(child) end |
#deepest? ⇒ Boolean
53 54 55 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 53 def deepest? deepest == 'Y' end |
#has_children? ⇒ Boolean
84 85 86 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 84 def has_children? @children.count > 0 end |
#obsolete? ⇒ Boolean
49 50 51 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 49 def obsolete? status == "Obsolete" end |
#remove_child(child) ⇒ Object
80 81 82 |
# File 'lib/academic_benchmarks/standards/standard.rb', line 80 def remove_child(child) @children.delete(child) end |