Last change
on this file since 238 was 232, checked in by KOBAYASHI, Shinji, 15 years ago |
move from test to rspec
|
File size:
1.6 KB
|
Line | |
---|
1 | # This module is implemented from this UML:
|
---|
2 | #http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109701308832_384250_6986Report.html
|
---|
3 | # Ticket refs #46
|
---|
4 |
|
---|
5 | require 'uri'
|
---|
6 |
|
---|
7 | module URI
|
---|
8 | class Ehr < ::URI::Generic
|
---|
9 | COMPONENT = [
|
---|
10 | :scheme, :path, :fragment, :query
|
---|
11 | ].freeze
|
---|
12 |
|
---|
13 | def self.build(args)
|
---|
14 | tmp = Util::make_components_hash(self, args)
|
---|
15 | super(tmp)
|
---|
16 | end
|
---|
17 |
|
---|
18 | def initialize(*arg)
|
---|
19 | super(*arg)
|
---|
20 | end
|
---|
21 |
|
---|
22 | def self.use_registry
|
---|
23 | true
|
---|
24 | end
|
---|
25 | end
|
---|
26 | @@schemes['EHR'] = Ehr
|
---|
27 | end
|
---|
28 |
|
---|
29 | module OpenEHR
|
---|
30 | module RM
|
---|
31 | module DataTypes
|
---|
32 | module Uri
|
---|
33 | class DvUri < OpenEHR::RM::DataTypes::Basic::DataValue
|
---|
34 | attr_reader :value
|
---|
35 |
|
---|
36 | def initialize(args ={})
|
---|
37 | self.value = args[:value]
|
---|
38 | end
|
---|
39 |
|
---|
40 | def fragment_id
|
---|
41 | @uri.fragment
|
---|
42 | end
|
---|
43 |
|
---|
44 | def path
|
---|
45 | @uri.path
|
---|
46 | end
|
---|
47 |
|
---|
48 | def query
|
---|
49 | @uri.query
|
---|
50 | end
|
---|
51 |
|
---|
52 | def scheme
|
---|
53 | @uri.scheme
|
---|
54 | end
|
---|
55 |
|
---|
56 | def value=(value)
|
---|
57 | raise ArgumentError, "value is empty" if value.nil?
|
---|
58 | parse(value)
|
---|
59 | @value = value
|
---|
60 | end
|
---|
61 |
|
---|
62 | private
|
---|
63 |
|
---|
64 | def parse(value)
|
---|
65 | @uri = ::URI.parse(value)
|
---|
66 | end
|
---|
67 | end
|
---|
68 |
|
---|
69 | class DvEhrUri < DvUri
|
---|
70 | def initialize(value)
|
---|
71 | super(value)
|
---|
72 | end
|
---|
73 |
|
---|
74 | def value=(value)
|
---|
75 | raise ArgumentError, "scheme must be ehr" if !(value =~ /^ehr/i)
|
---|
76 | super(value)
|
---|
77 | end
|
---|
78 | end # of DV_EHR_URI
|
---|
79 | end # of URI
|
---|
80 | end # of DataTypes
|
---|
81 | end # of RM
|
---|
82 | end # of OpenEHR
|
---|
Note:
See
TracBrowser
for help on using the repository browser.