Class: HQMF2::Value

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

Overview

Represents a bound within a HQMF pauseQuantity, has a value, a unit and an inclusive/exclusive indicator

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utilities

#attr_val, attr_val, #to_xml

Methods included from HQMF::Conversion::Utilities

#build_hash, #check_equality, #json_array, #openstruct_to_json

Constructor Details

#initialize(entry, default_type = 'PQ') ⇒ Value

Returns a new instance of Value.



23
24
25
26
27
28
# File 'lib/hqmf-parser/2.0/types.rb', line 23

def initialize(entry, default_type='PQ')
  @entry = entry
  @type = attr_val('./@xsi:type') || default_type
  @unit = attr_val('./@unit')
  @value = attr_val('./@value')
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



21
22
23
# File 'lib/hqmf-parser/2.0/types.rb', line 21

def type
  @type
end

#unitObject (readonly)

Returns the value of attribute unit.



21
22
23
# File 'lib/hqmf-parser/2.0/types.rb', line 21

def unit
  @unit
end

#valueObject (readonly)

Returns the value of attribute value.



21
22
23
# File 'lib/hqmf-parser/2.0/types.rb', line 21

def value
  @value
end

Instance Method Details

#derived?Boolean

Returns:

  • (Boolean)


39
40
41
42
43
44
45
46
# File 'lib/hqmf-parser/2.0/types.rb', line 39

def derived?
  case attr_val('./@nullFlavor')
  when 'DER'
    true
  else
    false
  end
end

#expressionObject



48
49
50
51
52
53
54
# File 'lib/hqmf-parser/2.0/types.rb', line 48

def expression
  if !derived?
    nil
  else
    attr_val('./cda:expression/@value')
  end
end

#inclusive?Boolean

Returns:

  • (Boolean)


30
31
32
33
34
35
36
37
# File 'lib/hqmf-parser/2.0/types.rb', line 30

def inclusive?
  case attr_val('./@inclusive')
  when 'false'
    false
  else
    true
  end
end

#to_modelObject



56
57
58
# File 'lib/hqmf-parser/2.0/types.rb', line 56

def to_model
  HQMF::Value.new(type,unit,value,inclusive?,derived?,expression)
end