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 219)
+++ 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
Index: ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_list_spec.rb
===================================================================
--- ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_list_spec.rb	(revision 219)
+++ ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_list_spec.rb	(revision 220)
@@ -7,8 +7,8 @@
   before(:each) do
     items = %w{one two three}.collect do |n|
-      Element.new(:name => DvText.new(n),
+      Element.new(:name => DvText.new(:value => n),
                   :archetype_node_id => 'test')
     end
-    item_list_name = DvText.new('item list')
+    item_list_name = DvText.new(:value => 'item list')
     @item_list = ItemList.new(:name => item_list_name,
                               :archetype_node_id => 'test',
@@ -32,5 +32,6 @@
 
   it 'retrieve the names of all items' do
-    @item_list.names.should == %w{one two three}.collect{|n| DvText.new(n)}
+    @item_list.names.should == %w{one two three}.collect{|n|
+      DvText.new(:value => n)}
   end
 
Index: ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_table_spec.rb
===================================================================
--- ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_table_spec.rb	(revision 219)
+++ ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_table_spec.rb	(revision 220)
@@ -7,5 +7,5 @@
 def row(args)
   return args.collect do |n|
-    Element.new(:name => DvText.new(n),
+    Element.new(:name => DvText.new(:value => n),
                 :archetype_node_id => 'test')
   end
@@ -13,5 +13,5 @@
 
 def cluster_builder(name,rows)
-  return Cluster.new(:name => DvText.new(name),
+  return Cluster.new(:name => DvText.new(:value => name),
                      :archetype_node_id => 'test',
                      :items => rows)
@@ -23,5 +23,5 @@
     row2 = row(%w{four five six})
     rows = [row1, row2].collect{|r| cluster_builder('cluster',r)}
-    @item_table = ItemTable.new(:name => DvText.new('item table'),
+    @item_table = ItemTable.new(:name => DvText.new(:value => 'item table'),
                                 :archetype_node_id => 'test',
                                 :rows => rows)
@@ -47,5 +47,6 @@
 
   it 's row_names should be cluster cluster' do
-    @item_table.row_names.should == %w{cluster cluster}.collect{|n| DvText.new(n)}
+    @item_table.row_names.should == %w{cluster cluster}.collect{|n|
+      DvText.new(:value => n)}
   end
 
@@ -56,5 +57,6 @@
 
   it 's column_names should one two three' do
-    @item_table.column_names.should == %w{one two three}.collect{|s| DvText.new(s)}
+    @item_table.column_names.should == %w{one two three}.collect{|s|
+      DvText.new(:value => s)}
   end
 
Index: ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_tree_spec.rb
===================================================================
--- ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_tree_spec.rb	(revision 219)
+++ ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_tree_spec.rb	(revision 220)
@@ -8,8 +8,8 @@
   before(:each) do
     items = %w{one two}.collect do |name|
-      Element.new(:name => DvText.new(name),
+      Element.new(:name => DvText.new(:value => name),
                   :archetype_node_id => 'test')
     end
-    name = DvText.new('item tree')
+    name = DvText.new(:value => 'item tree')
     @item_tree = ItemTree.new(:name => name,
                               :archetype_node_id => 'test',
Index: ruby/branches/0.5/spec/lib/open_ehr/rm/data_types/basic/dv_state_spec.rb
===================================================================
--- ruby/branches/0.5/spec/lib/open_ehr/rm/data_types/basic/dv_state_spec.rb	(revision 219)
+++ ruby/branches/0.5/spec/lib/open_ehr/rm/data_types/basic/dv_state_spec.rb	(revision 220)
@@ -3,9 +3,11 @@
 include OpenEHR::RM::Support::Identification
 include OpenEHR::RM::DataTypes::Text
+
 describe DvState do
   before(:each) do
     @terminology_id = TerminologyId.new('openher')
     code_phrase = CodePhrase.new('524', @terminology_id)
-    dv_coded_text = DvCodedText.new("initial", code_phrase)
+    dv_coded_text = DvCodedText.new(:value => "initial",
+                                    :defining_code => code_phrase)
     @dv_state = DvState.new(:value => dv_coded_text,
                             :is_terminal => false)
@@ -22,5 +24,6 @@
   it 'should change other value assigned' do
     code_phrase = CodePhrase.new('526',@terminology_id)
-    dv_coded_text = DvCodedText.new('planned', code_phrase)
+    dv_coded_text = DvCodedText.new(:value =>'planned',
+                                    :defining_code => code_phrase)
     lambda {
       @dv_state.value = dv_coded_text
