source:
ruby/branches/0.5/lib/open_ehr/rm/data_types/uri.rb@
232
Last change on this file since 232 was 232, checked in by , 15 years ago | |
---|---|
File size: 1.6 KB |
Rev | Line | |
---|---|---|
[104] | 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 | ||
[4] | 5 | require 'uri' |
[232] | 6 | |
[173] | 7 | module URI |
[167] | 8 | class Ehr < ::URI::Generic |
[4] | 9 | COMPONENT = [ |
10 | :scheme, :path, :fragment, :query | |
11 | ].freeze | |
[232] | 12 | |
[4] | 13 | def self.build(args) |
14 | tmp = Util::make_components_hash(self, args) | |
15 | super(tmp) | |
16 | end | |
[232] | 17 | |
[4] | 18 | def initialize(*arg) |
19 | super(*arg) | |
20 | end | |
[232] | 21 | |
[4] | 22 | def self.use_registry |
23 | true | |
24 | end | |
25 | end | |
[167] | 26 | @@schemes['EHR'] = Ehr |
[4] | 27 | end |
[104] | 28 | |
[216] | 29 | module OpenEHR |
[4] | 30 | module RM |
[167] | 31 | module DataTypes |
32 | module Uri | |
[216] | 33 | class DvUri < OpenEHR::RM::DataTypes::Basic::DataValue |
[232] | 34 | attr_reader :value |
35 | ||
[230] | 36 | def initialize(args ={}) |
37 | self.value = args[:value] | |
[4] | 38 | end |
[232] | 39 | |
[4] | 40 | def fragment_id |
[232] | 41 | @uri.fragment |
[4] | 42 | end |
[232] | 43 | |
[4] | 44 | def path |
[232] | 45 | @uri.path |
[4] | 46 | end |
[232] | 47 | |
[4] | 48 | def query |
[232] | 49 | @uri.query |
[4] | 50 | end |
[232] | 51 | |
[4] | 52 | def scheme |
[232] | 53 | @uri.scheme |
[4] | 54 | end |
[232] | 55 | |
[4] | 56 | def value=(value) |
[103] | 57 | raise ArgumentError, "value is empty" if value.nil? |
[4] | 58 | parse(value) |
[232] | 59 | @value = value |
[4] | 60 | end |
[232] | 61 | |
[4] | 62 | private |
[232] | 63 | |
[4] | 64 | def parse(value) |
[232] | 65 | @uri = ::URI.parse(value) |
[4] | 66 | end |
67 | end | |
[104] | 68 | |
[167] | 69 | class DvEhrUri < DvUri |
[4] | 70 | def initialize(value) |
71 | super(value) | |
72 | end | |
[232] | 73 | |
[4] | 74 | def value=(value) |
[103] | 75 | raise ArgumentError, "scheme must be ehr" if !(value =~ /^ehr/i) |
[232] | 76 | super(value) |
[4] | 77 | end |
78 | end # of DV_EHR_URI | |
79 | end # of URI | |
[167] | 80 | end # of DataTypes |
[4] | 81 | end # of RM |
82 | end # of OpenEHR |
Note:
See TracBrowser
for help on using the repository browser.