Class: HQMF1::Comparison

Inherits:
Object
  • Object
show all
Includes:
Utilities
Defined in:
lib/hqmf-parser/1.0/comparison.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utilities

#attr_val, #check_nil_conjunction_on_child, #clean_json, #clean_json_recursive

Methods included from HQMF::Conversion::Utilities

#build_hash, #check_equality, #json_array, #openstruct_to_json

Constructor Details

#initialize(data_criteria_id, entry, parent, doc) ⇒ Comparison

Returns a new instance of Comparison.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/hqmf-parser/1.0/comparison.rb', line 8

def initialize(data_criteria_id, entry, parent, doc)
  @doc = doc
  @data_criteria_id = data_criteria_id
  @entry = entry
  title_def = @entry.at_xpath('./*/cda:title')
  if title_def
    @title = title_def.inner_text
  end
  @restrictions = []
  restriction_def = @entry.at_xpath('./*/cda:sourceOf')
  if restriction_def
    @entry.xpath('./*/cda:sourceOf').each do |restriction|
      @restrictions << Restriction.new(restriction, self, @doc)
    end
  end
end

Instance Attribute Details

#data_criteria_idObject (readonly)

Returns the value of attribute data_criteria_id.



6
7
8
# File 'lib/hqmf-parser/1.0/comparison.rb', line 6

def data_criteria_id
  @data_criteria_id
end

#restrictionsObject (readonly)

Returns the value of attribute restrictions.



6
7
8
# File 'lib/hqmf-parser/1.0/comparison.rb', line 6

def restrictions
  @restrictions
end

#subsetObject (readonly)

Returns the value of attribute subset.



6
7
8
# File 'lib/hqmf-parser/1.0/comparison.rb', line 6

def subset
  @subset
end

#titleObject (readonly)

Returns the value of attribute title.



6
7
8
# File 'lib/hqmf-parser/1.0/comparison.rb', line 6

def title
  @title
end

Instance Method Details

#to_jsonObject



25
26
27
28
29
30
31
# File 'lib/hqmf-parser/1.0/comparison.rb', line 25

def to_json
  
  json = build_hash(self, [:data_criteria_id,:title,:subset])
  json[:restrictions] = json_array(@restrictions)
  json
  
end