Class: CommonCoreParser::Standard

Inherits:
Element show all
Defined in:
lib/common_core_parser/elements/standard.rb

Instance Attribute Summary

Attributes inherited from Element

#children_hash, #data

Instance Method Summary collapse

Methods inherited from Element

#add_child, #children, #code, #grades, #illigit?, #initialize, #parent, #parent_ref_id, #ref_id, #statement, #to_s, #valid?, #valid_grades?

Constructor Details

This class inherits a constructor from CommonCoreParser::Element

Instance Method Details

#clusterObject



18
19
20
# File 'lib/common_core_parser/elements/standard.rb', line 18

def cluster
  @cluster ||= self.parent.is_a?(Cluster) ? self.parent : nil
end

#domainObject



22
23
24
# File 'lib/common_core_parser/elements/standard.rb', line 22

def domain
  @domain ||= cluster ? cluster.parent : self.parent
end

#error_messageObject



14
15
16
# File 'lib/common_core_parser/elements/standard.rb', line 14

def error_message
  errors.join(',')
end

#errorsObject



4
5
6
7
8
9
10
11
12
# File 'lib/common_core_parser/elements/standard.rb', line 4

def errors
  errors = []
  errors << 'Refid is blank' if ref_id.blank?
  errors << 'PRI is blank' if parent_ref_id.blank?
  errors << 'Code is blank' if code.blank?
  errors << 'Statement is blank' if statement.blank?
  errors << 'invalid grades' unless valid_grades?
  return errors
end

#subjectObject



26
27
28
# File 'lib/common_core_parser/elements/standard.rb', line 26

def subject
  @subject ||= domain.try(:parent)
end