Index: ruby/branches/0.5/lib/open_ehr/rm/data_types/text.rb
===================================================================
--- ruby/branches/0.5/lib/open_ehr/rm/data_types/text.rb	(revision 218)
+++ ruby/branches/0.5/lib/open_ehr/rm/data_types/text.rb	(revision 220)
@@ -2,4 +2,6 @@
 # http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109067605961_209522_3179Report.html
 # Ticket refs #48
+include OpenEHR::RM::DataTypes::Basic
+
 module OpenEHR
   module RM
@@ -63,67 +65,52 @@
 
         class DvText < OpenEHR::RM::DataTypes::Basic::DataValue
-          attr_reader :value, :formatting, :hyperlink, :mappings
-          attr_reader :language, :encoding
-          def initialize(value, formatting = nil, hyperlink = nil,
-                         mappings = nil, language = nil, encoding = nil)
-            value_valid(value)
-            DvText.formatting_valid(formatting)
-            DvText.encoding_valid(encoding)
-            DvText.mapping_valid(mappings)
-            DvText.language_valid(language)
-            @value, @formatting, @encoding = value, formatting, encoding
-            @mappings, @language = mappings, language
+          attr_reader :formatting, :hyperlink, :mappings,
+                      :language, :encoding
+
+          def initialize(args = {})
+            super(args)
+            self.formatting = args[:formatting]
+            self.encoding = args[:encoding]
+            self.mappings = args[:mappings]
+            self.language = args[:language]
           end
+
           def value=(value)
-            value_valid(value)
+            if value.nil? or value.empty? or 
+                value.include? CR or value.include? LF
+              raise ArgumentError, "value is not valid"
+              # CR and LF are defined in Basic_Definition inherited DataValue.
+            end
             @value = value
           end
+
           def formatting=(formatting)
-            DvText.formatting_valid(formatting)
+            unless formatting.nil? or formatting.empty?
+              raise ArgumentError, "formatting is not valid"
+            end
             @formatting = formatting
           end
+
           def encoding=(encoding)
-            DvText.encoding_valid(encoding)
+            unless encoding.nil? or encoding.empty?
+              raise ArgumentError, "encoding is not valid"
+            end
             @encoding = encoding
           end
           def mappings=(mappings)
-            DvText.mapping_valid(mappings)
+            if !mappings.nil? and !mappings.instance_of? Set
+              raise ArgumentError, "mapping(s) is(are) not valid"
+            elsif !mappings.nil? and mappings.instance_of? Set and
+                mappings.empty?
+              raise ArgumentError, "mapping(s) is(are) not valid"
+            end
             @mappings = mappings
           end
           def language=(language)
-            DvText.language_valid(language)
+            unless language.nil? or language.empty?
+              raise ArgumentError, "langage is not valid"
+            end
             @language = language
           end
-          private
-          def value_valid(value)
-            if value.nil? or value.empty? or value.include? CR or value.include? LF
-              raise ArgumentError, "value is not valid"
-              # CR and LF are defined in Basic_Definition inherited DataValue.
-            end
-          end
-
-          class << self
-
-            def formatting_valid(formatting)
-              raise ArgumentError, "formatting is not valid" if formatting != nil and formatting.empty?
-            end
-
-            def encoding_valid(encoding)
-              raise ArgumentError, "encoding is not valid" if encoding != nil and encoding.empty?
-            end
-
-            def mapping_valid(mapping)
-              if !mapping.nil? and !mapping.instance_of? Set
-                raise ArgumentError, "mapping(s) is(are) not valid"
-              elsif !mapping.nil? and mapping.instance_of? Set
-                raise ArgumentError, "mapping(s) is(are) not valid" if mapping.empty? 
-              end
-            end
-
-            def language_valid(language)
-              raise ArgumentError, "langage is not valid" if language != nil and language.empty?
-            end
-          end
-
         end
 
@@ -131,14 +118,12 @@
           attr_reader :defining_code
 
-          def initialize(value, defining_code, formatting = nil, 
-                         hyperlink = nil, mappings = nil, language = nil, 
-                         encoding = nil)
-            super(value, formatting, hyperlink, mappings, language, encoding)
-            self.defining_code = defining_code
+          def initialize(args = {})
+            super(args)
+            self.defining_code = args[:defining_code]
           end
 
           def defining_code=(defining_code)
             if defining_code.nil?
-              raise ArgumentError, "Defiinition must be exist" 
+              raise ArgumentError, 'defiining code is mandatory'
             end
             @defining_code = defining_code
