Sha256: 9bc9fd1d1c10ca016100ec8adfc3beae861dec4fecc1e2b8617805bc2a890450

Contents?: true

Size: 1.92 KB

Versions: 1

Compression:

Stored size: 1.92 KB

Contents

# Author::    Nicolas Pouillard  <ertai@lrde.epita.fr>.
# Copyright:: Copyright (c) 2004, 2005 TTK team. All rights reserved.
# License::   LGPL
# $Id: Dumper.rb 575 2005-04-14 10:22:30Z polrop $


module TTK

  # Dumpers are backends of TTK.
  # You can easily write your own dumper.
  # For this, you only need to have a look to template/README,
  # and template/new_dumper.rb.
  module Dumpers

    # The dumper is a logger observer.
    # It's react to some messages, and can be compared to shell commands:
    #
    #   At any time `path' is "equivalent to" the shell command `pwd'.
    #
    #   - new_node:
    #     - You receive a message like that: [ :new_node, path ].
    #     - new_node is equivalent to `mkdir path && cd path' in shell.
    #
    #   - new_leaf:
    #     - message: [ :new_leaf, path, node ]
    #         Where `path' is the current path.
    #     - equivalent: `touch node'
    #
    #   - up:
    #     - message: [ :up, path ]
    #         Where `path' is the current path.
    #     - equivalent: `cd ..`
    #     - This notification change the current path to the parent.
    #
    #   - close:
    #     - message: [ :close ]
    #     - This notification close the dumper stream.
    class Dumper
      include Abstract

      def initialize ( output=STDOUT )
        @io = output
      end


      def new_node ( path )
      end
      protected :new_node


      def new_leaf ( path, node )
      end
      protected :new_leaf


      def up ( path )
      end
      protected :up


      def close
        #FIXME: some bugs appears with this line
#         @io.close unless @io.closed?
      end
      protected :close


      def update ( msg, *args )
	case msg
          when :up then up(*args)
          when :new_node then new_node(*args)
          when :new_leaf then new_leaf(*args)
          when :close then close(*args)
        end
      end

    end # class Dumper

  end # module Dumpers

end # module TTK

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ttk-0.1.576 lib/ttk/dumpers/Dumper.rb