File: model/docbook.rb

Overview
Module Structure
Class Hierarchy
Code

Overview

Module Structure

  module: <Toplevel Module>
  module: TmDoc#11
  module: Model
  module: DocBook#13
  module: Document#39
has properties
constant: EMPTY_SEQ_OF_DOCUMENT #84
  class: Abstract#41
includes
  Treeable ( TmStd )
inherits from
  GenericDocument ( TmDoc::Model::Abstraction )
has properties
attribute: name [R] #44
attribute: db_element [R] #44
attribute: documents [R] #44
alias: children documents #46
method: initialize / 3 #49
method: empty? #64
method: to_s #71
  class: SeqOfDocument#80
inherits from
  SeqOfGenericDocument ( TmDoc::Model::Abstraction )
has properties
constant: LSM_ELEMENT_CLASS #81
  class: Leaf#88
inherits from
  Abstract ( TmDoc::Model::DocBook::Document )
has properties
method: initialize / 2 #89
  class: Node#99
  class: Store#15
inherits from
  Store ( TmDoc::Model::Abstraction )
has properties
attribute: home [R] #16
method: initialize / 1 #19
method: print #26

Code

   1  # $Id: docbook.rb,v 1.5 2011/12/08 22:54:35 machan Exp $
   2 
   3  require 'stringio'
   4 
   5  require 'tmdoc/tmstd'
   6  require 'tmdoc/tmstd/treeable'
   7  require 'tmdoc/constant'
   8  require 'tmdoc/model/abstraction'
   9 
  10 
  11  module TmDoc
  12 
  13  module Model::DocBook
  14 
  15  class Store < Model::Abstraction::Store
  16      attr_reader :home
  17 
  18 
  19      def initialize(home)
  20          ASSERT.kind_of home, Document::Node
  21 
  22          @home = home
  23      end
  24 
  25 
  26      def print
  27          LOG::Debug.log '======== DocBook Model ========'
  28          str_io = StringIO.new
  29          self.home.print_tree(str_io)
  30          LOG::Debug.log str_io.string
  31          LOG::Debug.log
  32 
  33          nil
  34      end
  35  end
  36 
  37 
  38 
  39  module Document
  40 
  41  class Abstract < Model::Abstraction::GenericDocument
  42      include TmStd::Treeable
  43 
  44      attr_reader :name, :db_element, :documents
  45 
  46      alias children  documents
  47 
  48 
  49      def initialize(
  50          name, db_element, documents = EMPTY_SEQ_OF_DOCUMENT
  51      )
  52          ASSERT.kind_of  name,           String
  53          ASSERT.kind_of(
  54              db_element, TmStd::DocBook::Abstraction::Element
  55          )
  56          ASSERT.kind_of  documents,  SeqOfDocument
  57 
  58          @name       = name
  59          @db_element = db_element
  60          @documents  = documents
  61      end
  62 
  63 
  64      def empty?
  65          result = self.documents.empty?
  66 
  67          ASSERT.boolean result
  68      end
  69 
  70 
  71      def to_s
  72          str = format "%s (%s)", self.name, self.class.to_s
  73 
  74          ASSERT.kind_of str, String
  75      end
  76  end
  77 
  78 
  79 
  80  class SeqOfDocument < Model::Abstraction::SeqOfGenericDocument
  81      LSM_ELEMENT_CLASS = Abstract
  82  end
  83 
  84  EMPTY_SEQ_OF_DOCUMENT = SeqOfDocument.new
  85 
  86 
  87 
  88  class Leaf < Abstract
  89      def initialize(name, db_element)
  90          ASSERT.kind_of name,        String
  91          ASSERT.kind_of db_element,  TmStd::DocBook::Abstraction::Element
  92 
  93          super(name, db_element)
  94      end
  95  end
  96 
  97 
  98 
  99  class Node < Abstract; end
 100 
 101  end
 102 
 103  end # TmDoc::Model::DocBook
 104 
 105  end # TmDoc