Changeset 406


Ignore:
Timestamp:
Mar 12, 2010, 3:39:03 AM (13 years ago)
Author:
KOBAYASHI, Shinji
Message:

serializer implementation

Location:
ruby/trunk
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • ruby/trunk/lib/open_ehr/serializer.rb

    r405 r406  
    11require 'rexml/document'
     2require 'builder'
    23
    34module OpenEHR
     
    1415
    1516    class ADLSerializer < BaseSerializer
    16       def description
     17      def header
    1718        return <<HERE
    1819archetype (adl_version = #{@archetype.adl_version})
    19      #{@archetype.archetype_id.value}
     20\t#{@archetype.archetype_id.value}
     21
     22concept
     23\t[#{@archetype.concept}]
    2024HERE
     25      end
     26
     27      def description
     28
    2129      end
    2230
     
    3139
    3240      def merge
    33         return description + definition + ontology
     41        return header + description + definition + ontology
    3442      end
    3543    end
    3644
    3745    class XMLSerializer < BaseSerializer
     46
     47      def header
     48        header = ''
     49        xml = Builder::XmlMarkup.new(:indent => 2, :target => header)
     50        xml.archetype_id do
     51          xml.value @archetype.archetype_id.value
     52        end
     53        xml.concept @archetype.concept
     54        return header
     55      end
     56
    3857      def description
    39         desc = REXML::Element.new('archetype_id').
    40           add_text(@archetype.archetype_id.value)
    41         return desc
     58       
     59      end
     60
     61      def merge
     62
    4263      end
    4364    end
     
    5677
    5778class Writer
     79  def initialize(target)
     80    @target = target
     81  end
     82  def out
     83  end
    5884end
  • ruby/trunk/spec/models/archetype_datum_spec.rb

    r404 r406  
    1010      :text_data => "value for text_data",
    1111      :integer_data => 1,
    12       :real_data =>
     12      :real_data => 0.23
    1313    }
    1414  end
Note: See TracChangeset for help on using the changeset viewer.