Class: AcademicBenchmarks::Standards::Standard

Inherits:
Object
  • Object
show all
Includes:
InstVarsToHash
Defined in:
lib/academic_benchmarks/standards/standard.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from InstVarsToHash

#to_h, #to_s

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_yearObject

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

#authorityObject

Returns the value of attribute authority.



9
10
11
# File 'lib/academic_benchmarks/standards/standard.rb', line 9

def authority
  @authority
end

#childrenObject (readonly)

Returns the value of attribute children.



8
9
10
# File 'lib/academic_benchmarks/standards/standard.rb', line 8

def children
  @children
end

#courseObject

Returns the value of attribute course.



9
10
11
# File 'lib/academic_benchmarks/standards/standard.rb', line 9

def course
  @course
end

#deepestObject

Returns the value of attribute deepest.



8
9
10
# File 'lib/academic_benchmarks/standards/standard.rb', line 8

def deepest
  @deepest
end

#descriptionObject 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

#documentObject

Returns the value of attribute document.



9
10
11
# File 'lib/academic_benchmarks/standards/standard.rb', line 9

def document
  @document
end

#gradeObject

Returns the value of attribute grade.



9
10
11
# File 'lib/academic_benchmarks/standards/standard.rb', line 9

def grade
  @grade
end

#guidObject

Returns the value of attribute guid.



9
10
11
# File 'lib/academic_benchmarks/standards/standard.rb', line 9

def guid
  @guid
end

#has_relationsObject

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

#labelObject

Returns the value of attribute label.



9
10
11
# File 'lib/academic_benchmarks/standards/standard.rb', line 9

def label
  @label
end

#levelObject

Returns the value of attribute level.



9
10
11
# File 'lib/academic_benchmarks/standards/standard.rb', line 9

def level
  @level
end

#numberObject

Returns the value of attribute number.



9
10
11
# File 'lib/academic_benchmarks/standards/standard.rb', line 9

def number
  @number
end

#parentObject

Returns the value of attribute parent.



9
10
11
# File 'lib/academic_benchmarks/standards/standard.rb', line 9

def parent
  @parent
end

#parent_guidObject

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

#seqObject

Returns the value of attribute seq.



9
10
11
# File 'lib/academic_benchmarks/standards/standard.rb', line 9

def seq
  @seq
end

#statusObject

Returns the value of attribute status.



8
9
10
# File 'lib/academic_benchmarks/standards/standard.rb', line 8

def status
  @status
end

#stemObject

Returns the value of attribute stem.



9
10
11
# File 'lib/academic_benchmarks/standards/standard.rb', line 9

def stem
  @stem
end

#subjectObject

Returns the value of attribute subject.



9
10
11
# File 'lib/academic_benchmarks/standards/standard.rb', line 9

def subject
  @subject
end

#subject_docObject

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

#versionObject

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

Returns:

  • (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

Returns:

  • (Boolean)


53
54
55
# File 'lib/academic_benchmarks/standards/standard.rb', line 53

def deepest?
  deepest == 'Y'
end

#has_children?Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/academic_benchmarks/standards/standard.rb', line 84

def has_children?
  @children.count > 0
end

#obsolete?Boolean

Returns:

  • (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