Changeset 405


Ignore:
Timestamp:
Mar 8, 2010, 5:50:31 PM (13 years ago)
Author:
KOBAYASHI, Shinji
Message:

start serializer implementation

Location:
ruby/trunk
Files:
5 added
1 deleted
1 edited

Legend:

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

    r404 r405  
     1require 'rexml/document'
     2
    13module OpenEHR
    2   class Serializer
    3    
     4  module Serializer
     5    class BaseSerializer
     6      def initialize(archetype)
     7        @archetype = archetype
     8      end
     9
     10      def serialize
     11        return self.merge
     12      end
     13    end
     14
     15    class ADLSerializer < BaseSerializer
     16      def description
     17        return <<HERE
     18archetype (adl_version = #{@archetype.adl_version})
     19     #{@archetype.archetype_id.value}
     20HERE
     21      end
     22
     23      def definition
     24      end
     25
     26      def ontology
     27      end
     28
     29      def envelope
     30      end
     31
     32      def merge
     33        return description + definition + ontology
     34      end
     35    end
     36
     37    class XMLSerializer < BaseSerializer
     38      def description
     39        desc = REXML::Element.new('archetype_id').
     40          add_text(@archetype.archetype_id.value)
     41        return desc
     42      end
     43    end
     44  end
     45end
     46
     47class Publisher
     48  def initialize(serializer)
     49    @serializer = serializer
    450  end
    551
    6   class ADLSerializer < Serializer
    7 
    8   end
    9 
    10   class XMLSerializer < Serializer
    11 
     52  def publish(writer)
     53    writer.out(@serializer.serialize)
    1254  end
    1355end
     56
     57class Writer
     58end
Note: See TracChangeset for help on using the changeset viewer.