Class: OpenEHR::AM::Archetype::ConstraintModel::Primitive::CString
- Inherits:
-
CPrimitive
- Object
- CPrimitive
- OpenEHR::AM::Archetype::ConstraintModel::Primitive::CString
- Defined in:
- lib/openehr/am/archetype/constraint_model/primitive.rb
Instance Attribute Summary collapse
-
#list ⇒ Object
Returns the value of attribute list.
-
#list_open ⇒ Object
Returns the value of attribute list_open.
-
#pattern ⇒ Object
Returns the value of attribute pattern.
Attributes inherited from CPrimitive
#assumed_value, #default_value, #type
Instance Method Summary collapse
-
#initialize(args = { }) ⇒ CString
constructor
A new instance of CString.
- #valid_value?(value) ⇒ Boolean
Methods inherited from CPrimitive
Constructor Details
#initialize(args = { }) ⇒ CString
Returns a new instance of CString.
86 87 88 89 90 91 92 93 |
# File 'lib/openehr/am/archetype/constraint_model/primitive.rb', line 86 def initialize(args = { }) args[:type] = 'String' super consistency(args[:pattern], args[:list]) @pattern = args[:pattern] @list = args[:list] @list_open = args[:list_open] end |
Instance Attribute Details
#list ⇒ Object
Returns the value of attribute list.
83 84 85 |
# File 'lib/openehr/am/archetype/constraint_model/primitive.rb', line 83 def list @list end |
#list_open ⇒ Object
Returns the value of attribute list_open.
84 85 86 |
# File 'lib/openehr/am/archetype/constraint_model/primitive.rb', line 84 def list_open @list_open end |
#pattern ⇒ Object
Returns the value of attribute pattern.
83 84 85 |
# File 'lib/openehr/am/archetype/constraint_model/primitive.rb', line 83 def pattern @pattern end |
Instance Method Details
#valid_value?(value) ⇒ Boolean
105 106 107 108 109 110 111 |
# File 'lib/openehr/am/archetype/constraint_model/primitive.rb', line 105 def valid_value?(value) return false unless value.is_a?(String) return true if pattern.nil? && list.nil? return list.include?(value) if list Regexp.new(pattern).match?(value) end |