Class: HQMF2::Precondition
- Inherits:
-
Object
- Object
- HQMF2::Precondition
- Includes:
- Utilities
- Defined in:
- lib/hqmf-parser/2.0/precondition.rb
Instance Attribute Summary collapse
-
#preconditions ⇒ Object
readonly
Returns the value of attribute preconditions.
-
#reference ⇒ Object
readonly
Returns the value of attribute reference.
Instance Method Summary collapse
-
#conjunction? ⇒ Boolean
Return true of this precondition represents a conjunction with nested preconditions or false of this precondition is a reference to a data criteria.
-
#conjunction_code ⇒ String
Get the conjunction code, e.g.
-
#initialize(entry, doc) ⇒ Precondition
constructor
A new instance of Precondition.
- #to_model ⇒ Object
Methods included from Utilities
Methods included from HQMF::Conversion::Utilities
#build_hash, #check_equality, #json_array, #openstruct_to_json
Constructor Details
#initialize(entry, doc) ⇒ Precondition
Returns a new instance of Precondition.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/hqmf-parser/2.0/precondition.rb', line 9 def initialize(entry, doc) @doc = doc @entry = entry @preconditions = @entry.xpath('./*/cda:precondition', HQMF2::Document::NAMESPACES).collect do |precondition| Precondition.new(precondition, @doc) end reference_def = @entry.at_xpath('./*/cda:id', HQMF2::Document::NAMESPACES) if reference_def @reference = Reference.new(reference_def) end end |
Instance Attribute Details
#preconditions ⇒ Object (readonly)
Returns the value of attribute preconditions.
7 8 9 |
# File 'lib/hqmf-parser/2.0/precondition.rb', line 7 def preconditions @preconditions end |
#reference ⇒ Object (readonly)
Returns the value of attribute reference.
7 8 9 |
# File 'lib/hqmf-parser/2.0/precondition.rb', line 7 def reference @reference end |
Instance Method Details
#conjunction? ⇒ Boolean
Return true of this precondition represents a conjunction with nested preconditions or false of this precondition is a reference to a data criteria
23 24 25 |
# File 'lib/hqmf-parser/2.0/precondition.rb', line 23 def conjunction? @preconditions.length>0 end |
#conjunction_code ⇒ String
Get the conjunction code, e.g. allTrue, allFalse
29 30 31 32 33 34 35 |
# File 'lib/hqmf-parser/2.0/precondition.rb', line 29 def conjunction_code if conjunction? @entry.at_xpath('./*[1]', HQMF2::Document::NAMESPACES).name else nil end end |
#to_model ⇒ Object
37 38 39 40 41 |
# File 'lib/hqmf-parser/2.0/precondition.rb', line 37 def to_model pcs = preconditions.collect {|p| p.to_model} mr = reference ? reference.to_model : nil HQMF::Precondition.new(nil, pcs, mr, conjunction_code, false) end |