Class: OpenEHR::Parser::ADLParser
- Defined in:
- lib/open_ehr/parser/adl_parser.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(filename) ⇒ ADLParser
constructor
A new instance of ADLParser.
- #parse ⇒ Object
Constructor Details
#initialize(filename) ⇒ ADLParser
Returns a new instance of ADLParser.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/open_ehr/parser/adl_parser.rb', line 13 def initialize(filename) super(filename) file = File.open(filename, 'r:bom|utf-8') data = file.read Treetop.load(File.dirname(__FILE__)+'/adl_grammar.tt') ap = ADLGrammarParser.new @result = ap.parse(data) file.close unless @result puts ap.failure_reason puts ap.failure_line puts ap.failure_column end end |
Instance Method Details
#parse ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/open_ehr/parser/adl_parser.rb', line 28 def parse archetype_id = ArchetypeID.new(:value => @result.archetype_id) definition = @result.definition ontology = @result.ontology original_language = nil if @result.original_language original_language = @result.original_language else terminology_id = TerminologyID.new(:value => 'ISO639-1') original_language = CodePhrase.new(:terminology_id => terminology_id, :code_string =>ontology.primary_language) end archetype = Archetype.new(:archetype_id => archetype_id, :adl_version => @result.adl_version, :concept => @result.concept, :original_language => original_language, :translations => @result.translations, :description => @result.description, :definition => @result.definition, :ontology => @result.ontology) return archetype end |