Class: NcsNavigator::Mdes::Specification
- Inherits:
-
Object
- Object
- NcsNavigator::Mdes::Specification
- Extended by:
- Forwardable
- Defined in:
- lib/ncs_navigator/mdes/specification.rb
Instance Attribute Summary collapse
-
#source_documents ⇒ SourceDocuments
The source documents this reader is working from.
Instance Method Summary collapse
-
#[](criterion) ⇒ Object
A shortcut for accessing particular #transmission_tables.
- #diff(other, options = {}) ⇒ Object
-
#disposition_codes ⇒ Array<DispositionCode>
All the named disposition codes in the MDES.
-
#heuristic_overrides ⇒ Hash
The loaded heuristic overrides, or a default (empty) set.
-
#initialize(version, options = {}) ⇒ Specification
constructor
A new instance of Specification.
-
#inspect ⇒ String
A briefer inspection for nicer IRB sessions.
-
#specification_version ⇒ String
The exact version this specification matches.
-
#transmission_tables ⇒ Array<TransmissionTable>
All the transmission tables in this version of the MDES.
-
#types ⇒ Array<VariableType>
All the named types in the MDES.
-
#version ⇒ String
The version of the MDES to which this instance refers.
-
#xsd ⇒ Nokogiri::XML::Document
The parsed version of the VDR XML schema for this version of the MDES.
Constructor Details
#initialize(version, options = {}) ⇒ Specification
Returns a new instance of Specification.
36 37 38 39 40 41 42 43 44 |
# File 'lib/ncs_navigator/mdes/specification.rb', line 36 def initialize(version, ={}) @source_documents = case version when SourceDocuments version else SourceDocuments.get(version) end @log = [:log] || NcsNavigator::Mdes.default_logger end |
Instance Attribute Details
#source_documents ⇒ SourceDocuments
Returns the source documents this reader is working from.
15 16 17 |
# File 'lib/ncs_navigator/mdes/specification.rb', line 15 def source_documents @source_documents end |
Instance Method Details
#[](table_name) ⇒ TransmissionTable? #[](pattern) ⇒ Array<TransmissionTable>
A shortcut for accessing particular #transmission_tables.
148 149 150 151 152 153 154 155 156 157 |
# File 'lib/ncs_navigator/mdes/specification.rb', line 148 def [](criterion) case criterion when Regexp transmission_tables.select { |t| t.name =~ criterion } when String transmission_tables.detect { |t| t.name == criterion } else fail "Unexpected criterion #{criterion.inspect}" end end |
#diff(other, options = {}) ⇒ Object
208 209 210 |
# File 'lib/ncs_navigator/mdes/specification.rb', line 208 def diff(other, ={}) Differences::Entry.compute(self, other, DIFF_CRITERIA, ) end |
#disposition_codes ⇒ Array<DispositionCode>
Returns all the named disposition codes in the MDES.
175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/ncs_navigator/mdes/specification.rb', line 175 def disposition_codes @disposition_codes ||= begin if File.exist?(source_documents.disposition_codes) YAML.load(File.read source_documents.disposition_codes).collect do |dc| DispositionCode.new(dc) end else empty_disposition_codes end end end |
#heuristic_overrides ⇒ Hash
Returns the loaded heuristic overrides, or a default (empty) set.
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/ncs_navigator/mdes/specification.rb', line 56 def heuristic_overrides @heuristic_overrides ||= begin if File.exist?(source_documents.heuristic_overrides) empty_overrides.merge(YAML.load(File.read source_documents.heuristic_overrides)) else empty_overrides end end end |
#inspect ⇒ String
A briefer inspection for nicer IRB sessions.
197 198 199 |
# File 'lib/ncs_navigator/mdes/specification.rb', line 197 def inspect "#<#{self.class} version=#{version.inspect}>" end |
#specification_version ⇒ String
Returns the exact version this specification matches. It may be more exact than the requested version due to applied patches.
27 |
# File 'lib/ncs_navigator/mdes/specification.rb', line 27 def_delegator :@source_documents, :specification_version |
#transmission_tables ⇒ Array<TransmissionTable>
Returns all the transmission tables in this version of the MDES.
77 78 79 |
# File 'lib/ncs_navigator/mdes/specification.rb', line 77 def transmission_tables @transmission_tables ||= read_transmission_tables end |
#types ⇒ Array<VariableType>
Returns all the named types in the MDES. This includes all the code lists.
162 163 164 |
# File 'lib/ncs_navigator/mdes/specification.rb', line 162 def types @types ||= read_types end |
#version ⇒ String
Returns the version of the MDES to which this instance refers.
20 |
# File 'lib/ncs_navigator/mdes/specification.rb', line 20 def_delegator :@source_documents, :version |
#xsd ⇒ Nokogiri::XML::Document
Returns the parsed version of the VDR XML schema for this version of the MDES.
49 50 51 |
# File 'lib/ncs_navigator/mdes/specification.rb', line 49 def xsd @xsd ||= Nokogiri::XML(File.read source_documents.schema) end |