Sha256: d42e1f1d70c1ac7c8a2873ac959c1057400fe92860804850f306ab26a7b9e443

Contents?: true

Size: 1.23 KB

Versions: 5

Compression:

Stored size: 1.23 KB

Contents

# Author::    Nicolas Despres  <nicolas.despres@gmail.com>.
# Copyright:: Copyright (c) 2004, 2005 TTK team. All rights reserved.
# License::   LGPL
# $Id: Client.rb 567 2005-04-13 08:00:06Z polrop $


module TTK

  module Monitors

    class Client
      include DRb::DRbUndumped

      def initialize(service, monitor)
        @service = service
        @monitor = monitor
        @monitor.add_observer(self)
      end

      attr_reader :monitor

      def uri
        @service.uri
      end

      def update(service, type, time, *args, &block)
        puts " - service: #{service}"
        puts "   type: #{type}"
        puts "   time: #{time}"
        begin
          contents = pp_contents(type, *args)
        rescue
          contents = $!.long_pp
        end
        puts "   contents: \"#{contents}\""
      end

      protected
      def pp_contents(type, *args)
        case type
        when :add_observer
        when :start_strategy
          #FIXME: use the dumper to dump the doc properly
          args[0].inspect
        when :stop_strategy
          "doc: #{args[0].inspect} ; result: #{args[1].inspect}"
        else
          args.inspect
        end
      end


    end # class Client

  end # module Monitors

end # module TTK




Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ttk-0.1.576 lib/ttk/monitors/Client.rb
ttk-0.1.580 lib/ttk/monitors/Client.rb
ttk-0.1.579 lib/ttk/monitors/Client.rb
ttk-0.2.0 lib/ttk/monitors/Client.rb
ttk-0.2.1 lib/ttk/monitors/Client.rb