Class: SimpleXml::TemporalReference

Inherits:
Object
  • Object
show all
Includes:
Utilities
Defined in:
lib/model/types.rb

Constant Summary

Constants included from Utilities

Utilities::MEASURE_ATTRIBUTES_MAP

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utilities

#attr_val, attr_val, build_value, #children_of, #comments_on, #create_age_timing, #create_birthdate_criteria

Constructor Details

#initialize(type, comparison, quantity, unit, reference) ⇒ TemporalReference

Returns a new instance of TemporalReference.



161
162
163
164
165
# File 'lib/model/types.rb', line 161

def initialize(type, comparison, quantity, unit, reference)
  @type = translate_type(type)
  @range = SimpleXml::Range.new(comparison, quantity, unit, 'IVL_PQ') if comparison
  @reference = Reference.new(reference.id)
end

Instance Attribute Details

#rangeObject (readonly)

Returns the value of attribute range.



159
160
161
# File 'lib/model/types.rb', line 159

def range
  @range
end

#referenceObject (readonly)

Returns the value of attribute reference.



159
160
161
# File 'lib/model/types.rb', line 159

def reference
  @reference
end

#typeObject

Returns the value of attribute type.



158
159
160
# File 'lib/model/types.rb', line 158

def type
  @type
end

Instance Method Details

#to_modelObject



188
189
190
191
# File 'lib/model/types.rb', line 188

def to_model
  rm = range ? range.to_model : nil
  HQMF::TemporalReference.new(type, reference.to_model, rm)
end

#translate_type(type) ⇒ Object



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/model/types.rb', line 167

def translate_type(type)
  # todo: we now have SBDU
  type = 'SBE' if type == 'SBOD'
  type = 'EBE' if type == 'EBOD'
  # the above two lines are required for legacy tests
  type = 'EACW' if type == 'EAOCW' || type == 'EAEORECW'
  type = 'EACWS' if type == 'EAOCWSO' || type == 'EASORECWS'
  type = 'EBCW' if type == 'EBOCW' || type == 'EBEORECW'
  type = 'EBCWS' if type == 'EBOCWSO' || type == 'EBSORECWS'
  type = 'ECWS' if type == 'ECWSO'
  type = 'SACWE' if type == 'SAOCWEO' || type == 'SAEORSCWE'
  type = 'SACW' if type == 'SAOCW' || type == 'SASORSCW'
  type = 'SBCWE' if type == 'SBOCWEO' || type == 'SBEORSCWE'
  type = 'SBCW' if type == 'SBOCW' || type == 'SBSORSCW'
  type = 'SCWE' if type == 'SCWEO'
  type = 'OVERLAP' if type == 'Overlaps' || type == 'Overlap'

  raise "unknown temporal reference type #{type}" unless HQMF::TemporalReference::TYPES.include? type
  type
end