Module: HQMF2::Utilities
- Includes:
- HQMF::Conversion::Utilities
- Included in:
- Coded, DataCriteria, DataCriteriaBaseExtractions, Document, DocumentPopulationHelper, PopulationCriteria, Precondition, Range, Reference, SpecificOccurrenceAndSource, SubsetOperator, TemporalReference, TypedReference, Value, HQMF2CQL::DocumentPopulationHelper
- Defined in:
- lib/hqmf-parser/2.0/utilities.rb
Overview
Module containing parser helper functions
Defined Under Namespace
Classes: IdGenerator
Class Method Summary collapse
-
.attr_val(node, xpath) ⇒ Object
Utility function to handle optional attributes.
Instance Method Summary collapse
-
#attr_val(xpath) ⇒ Object
Utility function to handle optional attributes.
-
#strip_tokens(value) ⇒ Object
General helper for stripping ‘-’ and ‘,’ into ‘_’ for processable ids.
- #to_xml ⇒ Object
Methods included from HQMF::Conversion::Utilities
#build_hash, #check_equality, #json_array, #openstruct_to_json
Class Method Details
.attr_val(node, xpath) ⇒ Object
Utility function to handle optional attributes
16 17 18 19 |
# File 'lib/hqmf-parser/2.0/utilities.rb', line 16 def self.attr_val(node, xpath) attr = node.at_xpath(xpath, HQMF2::Document::NAMESPACES) return attr.value if attr end |
Instance Method Details
#attr_val(xpath) ⇒ Object
Utility function to handle optional attributes
9 10 11 |
# File 'lib/hqmf-parser/2.0/utilities.rb', line 9 def attr_val(xpath) Utilities.attr_val(@entry, xpath) end |
#strip_tokens(value) ⇒ Object
General helper for stripping ‘-’ and ‘,’ into ‘_’ for processable ids
26 27 28 29 30 31 |
# File 'lib/hqmf-parser/2.0/utilities.rb', line 26 def strip_tokens(value) return nil if value.nil? stripped = value.gsub(/[^0-9a-z]/i, '_') # Prefix digits with 'prefix_' to prevent JS syntax errors stripped.gsub(/^[0-9]/, "prefix_#{value[0]}") end |
#to_xml ⇒ Object
21 22 23 |
# File 'lib/hqmf-parser/2.0/utilities.rb', line 21 def to_xml @entry.to_xml end |