source: ruby/branches/0.5/lib/open_ehr/rm/data_types/basic.rb@ 216

Last change on this file since 216 was 216, checked in by KOBAYASHI, Shinji, 15 years ago

move from Test:Unit to RSpec

File size: 2.2 KB
RevLine 
[89]1# This module is implemented from this UML:
2# http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109067591791_562382_3151Report.html
3# Ticket refs #52
[216]4module OpenEHR
[4]5 module RM
[167]6 module DataTypes
[4]7 module Basic
[167]8 module CanonicalFragment
[4]9 end
10
[167]11 class DataValue
[216]12 include OpenEHR::RM::Support::Definition::BasicDefinition
13 attr_accessor :value
14 alias :v :value
15
16 def initialize(args = {})
17 self.value = args[:value]
18 end
19
[195]20 def ==(other)
21 return self.value == other.value
22 end
[4]23 end
24
[167]25 class DvBoolean < DataValue
[216]26 def initialize(args)
27 super(args)
[106]28 end
[216]29
[106]30 def value=(value)
31 raise ArgumentError, "value must not be nil" if value.nil?
[109]32 if value == true or value =~ /TRUE/i
[4]33 @value = true
34 else
35 @value = false
36 end
37 end
[195]38
[4]39 def value?
40 @value == true
41 end
[167]42 end # end of DvBoolean
[4]43
[167]44 class DvState < DataValue
[216]45 attr_reader :is_terminal
[89]46
[216]47 def initialize(args)
48 super(args)
49 self.is_terminal = args[:is_terminal]
[4]50 end
[216]51
[89]52 def value=(v)
53 raise ArgumentError, "value should not be nil" if v.nil?
54 @value = v
55 end
[216]56
[4]57 def is_terminal?
[89]58 @is_terminal
[4]59 end
[216]60
[89]61 def is_terminal=(s)
62 raise ArgumentError, "terminal should not be nil" if s.nil?
63 @is_terminal = s
64 end
[167]65 end # end of DvState
[4]66
[167]67 class DvIdentifier
[216]68 attr_reader :issuer, :assigner, :id, :type
69
70 def initialize(args = {})
[106]71 if assigner.nil? or assigner.empty?\
72 or id.nil? or id.empty? or issuer.nil? or issuer.empty?\
73 or type.nil? or type.empty?
[4]74 raise ArgumentError, "invalid argument"
75 end
76 @issuer = issuer
77 @assigner = assigner
78 @id = id
79 @type = type
80 end
[167]81 end #end of DvIdentifier
[4]82 end # end of Basic
[167]83 end # end of DataTypes
[4]84 end # end of RM
85end # end of OpenEHR
Note: See TracBrowser for help on using the repository browser.