Class: HQMF2::Reference

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

Overview

Represents a HQMF reference from a precondition to a data criteria

Instance Method Summary collapse

Methods included from Utilities

#attr_val, attr_val, #strip_tokens, #to_xml

Methods included from HQMF::Conversion::Utilities

#build_hash, #check_equality, #json_array, #openstruct_to_json

Constructor Details

#initialize(entry) ⇒ Reference

Returns a new instance of Reference.



400
401
402
# File 'lib/hqmf-parser/2.0/types.rb', line 400

def initialize(entry)
  @entry = entry
end

Instance Method Details

#idObject

Generates the id to use for a reference



405
406
407
408
409
410
411
412
413
414
# File 'lib/hqmf-parser/2.0/types.rb', line 405

def id
  if @entry.is_a? String
    @entry
  else
    id = strip_tokens("#{attr_val('./@extension')}_#{attr_val('./@root')}")
    # Handle MeasurePeriod references for calculation code
    id = 'MeasurePeriod' if id.try(:start_with?, 'measureperiod')
    id
  end
end

#to_modelObject

Generates this classes hqmf-model equivalent



417
418
419
# File 'lib/hqmf-parser/2.0/types.rb', line 417

def to_model
  HQMF::Reference.new(id)
end