Class: OpenEHR::AM::OpenEHRProfile::DataTypes::Quantity::CDvScale

Inherits:
Archetype::ConstraintModel::CDomainType show all
Defined in:
lib/openehr/am/openehr_profile/data_types/quantity.rb

Overview

RM 1.1.0: the AOM constraint for DV_SCALE, mirroring CDvOrdinal (an enumeration of allowed value/symbol pairs) except DV_SCALE.value is Real rather than Integer.

Instance Attribute Summary collapse

Attributes inherited from Archetype::ConstraintModel::CDefinedObject

#assumed_value

Attributes inherited from Archetype::ConstraintModel::CObject

#node_id, #occurrences, #rm_type_name

Attributes inherited from Archetype::ConstraintModel::ArchetypeConstraint

#parent, #path

Instance Method Summary collapse

Methods inherited from Archetype::ConstraintModel::CDomainType

#standard_equivalent

Methods inherited from Archetype::ConstraintModel::CDefinedObject

#default_value, #has_assumed_value?

Methods inherited from Archetype::ConstraintModel::CObject

#node_conforms_to?, #path, #to_rm

Methods inherited from Archetype::ConstraintModel::ArchetypeConstraint

#congruent?, #has_path?, #node_conforms_to?

Constructor Details

#initialize(args = { }) ⇒ CDvScale

Returns a new instance of CDvScale.



74
75
76
77
# File 'lib/openehr/am/openehr_profile/data_types/quantity.rb', line 74

def initialize(args = { })
  super
  self.list = args[:list]
end

Instance Attribute Details

#list ⇒ Object

Returns the value of attribute list.



72
73
74
# File 'lib/openehr/am/openehr_profile/data_types/quantity.rb', line 72

def list
  @list
end

Instance Method Details

#any_allowed? ⇒ Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/openehr/am/openehr_profile/data_types/quantity.rb', line 79

def any_allowed?
  @list.nil?
end

#valid_value?(value) ⇒ Boolean

Returns:

  • (Boolean)


83
84
85
86
87
88
89
90
# File 'lib/openehr/am/openehr_profile/data_types/quantity.rb', line 83

def valid_value?(value)
  return true if any_allowed?
  return false unless value.respond_to?(:value) && value.respond_to?(:symbol)

  list.any? do |item|
    item.value == value.value && symbol_code(item.symbol) == symbol_code(value.symbol)
  end
end