Class: HQMF2::TypedReference

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

Overview

Represents a HQMF reference to a data criteria that has a given type

Instance Attribute Summary collapse

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, type = nil, verbose = false) ⇒ TypedReference

Create a new HQMF::Reference

Parameters:

  • id (String)


376
377
378
379
380
381
382
# File 'lib/hqmf-parser/2.0/types.rb', line 376

def initialize(entry, type = nil, verbose = false)
  @entry = entry
  @type = type || attr_val('./@classCode')
  @mood = attr_val('./@moodCode')
  @entry = entry.elements.first unless entry.at_xpath('./@extension')
  @verbose = verbose
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



372
373
374
# File 'lib/hqmf-parser/2.0/types.rb', line 372

def id
  @id
end

#moodObject

Returns the value of attribute mood.



372
373
374
# File 'lib/hqmf-parser/2.0/types.rb', line 372

def mood
  @mood
end

#typeObject

Returns the value of attribute type.



372
373
374
# File 'lib/hqmf-parser/2.0/types.rb', line 372

def type
  @type
end

Instance Method Details

#referenceObject

Generate the reference for the typed reference to use



385
386
387
388
# File 'lib/hqmf-parser/2.0/types.rb', line 385

def reference
  value = "#{attr_val('./@extension')}_#{attr_val('./@root')}"
  strip_tokens(value)
end

#to_modelObject

Generates this classes hqmf-model equivalent



391
392
393
# File 'lib/hqmf-parser/2.0/types.rb', line 391

def to_model
  HQMF::TypedReference.new(reference, @type, @mood)
end