Class: TTK::Dumpers::Dumper
- Includes:
- Abstract
- Defined in:
- lib/ttk/dumpers/Dumper.rb
Overview
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.
Instance Method Summary collapse
- #flush ⇒ Object
-
#initialize(output = STDOUT) ⇒ Dumper
constructor
A new instance of Dumper.
- #update(msg, *args) ⇒ Object
Constructor Details
#initialize(output = STDOUT) ⇒ Dumper
Returns a new instance of Dumper.
41 42 43 44 |
# File 'lib/ttk/dumpers/Dumper.rb', line 41 def initialize ( output=STDOUT ) @io = output @flushable = @io.respond_to?(:flush) end |
Instance Method Details
#flush ⇒ Object
62 63 64 |
# File 'lib/ttk/dumpers/Dumper.rb', line 62 def flush @io.flush if @flushable and (not @io.closed?) end |
#update(msg, *args) ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/ttk/dumpers/Dumper.rb', line 74 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 |