Last change
on this file since 217 was 216, checked in by KOBAYASHI, Shinji, 15 years ago |
move from Test:Unit to RSpec
|
File size:
2.2 KB
|
Line | |
---|
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
|
---|
4 | module OpenEHR
|
---|
5 | module RM
|
---|
6 | module DataTypes
|
---|
7 | module Basic
|
---|
8 | module CanonicalFragment
|
---|
9 | end
|
---|
10 |
|
---|
11 | class DataValue
|
---|
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 |
|
---|
20 | def ==(other)
|
---|
21 | return self.value == other.value
|
---|
22 | end
|
---|
23 | end
|
---|
24 |
|
---|
25 | class DvBoolean < DataValue
|
---|
26 | def initialize(args)
|
---|
27 | super(args)
|
---|
28 | end
|
---|
29 |
|
---|
30 | def value=(value)
|
---|
31 | raise ArgumentError, "value must not be nil" if value.nil?
|
---|
32 | if value == true or value =~ /TRUE/i
|
---|
33 | @value = true
|
---|
34 | else
|
---|
35 | @value = false
|
---|
36 | end
|
---|
37 | end
|
---|
38 |
|
---|
39 | def value?
|
---|
40 | @value == true
|
---|
41 | end
|
---|
42 | end # end of DvBoolean
|
---|
43 |
|
---|
44 | class DvState < DataValue
|
---|
45 | attr_reader :is_terminal
|
---|
46 |
|
---|
47 | def initialize(args)
|
---|
48 | super(args)
|
---|
49 | self.is_terminal = args[:is_terminal]
|
---|
50 | end
|
---|
51 |
|
---|
52 | def value=(v)
|
---|
53 | raise ArgumentError, "value should not be nil" if v.nil?
|
---|
54 | @value = v
|
---|
55 | end
|
---|
56 |
|
---|
57 | def is_terminal?
|
---|
58 | @is_terminal
|
---|
59 | end
|
---|
60 |
|
---|
61 | def is_terminal=(s)
|
---|
62 | raise ArgumentError, "terminal should not be nil" if s.nil?
|
---|
63 | @is_terminal = s
|
---|
64 | end
|
---|
65 | end # end of DvState
|
---|
66 |
|
---|
67 | class DvIdentifier
|
---|
68 | attr_reader :issuer, :assigner, :id, :type
|
---|
69 |
|
---|
70 | def initialize(args = {})
|
---|
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?
|
---|
74 | raise ArgumentError, "invalid argument"
|
---|
75 | end
|
---|
76 | @issuer = issuer
|
---|
77 | @assigner = assigner
|
---|
78 | @id = id
|
---|
79 | @type = type
|
---|
80 | end
|
---|
81 | end #end of DvIdentifier
|
---|
82 | end # end of Basic
|
---|
83 | end # end of DataTypes
|
---|
84 | end # end of RM
|
---|
85 | end # end of OpenEHR
|
---|
Note:
See
TracBrowser
for help on using the repository browser.