Class: Command::Results::TextFormatter
- Defined in:
- lib/command-set/formatter/base.rb
Overview
The simplest useful Formatter: it outputs the value of every item in tree order. Think of it as what would happen if you just let puts and p go directly to the screen, without the annoying consequences of threading, etc.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Formatter
Class Method Summary collapse
Instance Method Summary collapse
- #closed_item(value) ⇒ Object
-
#initialize(out = nil, err = nil) ⇒ TextFormatter
constructor
A new instance of TextFormatter.
Methods inherited from Formatter
#apply_advice, #closed_begin_list, #closed_end_list, #default_advice, #finish, #notify, #receive_advice, #saw_begin_list, #saw_end_list, #saw_item, #start
Constructor Details
#initialize(out = nil, err = nil) ⇒ TextFormatter
Returns a new instance of TextFormatter.
172 173 174 175 176 |
# File 'lib/command-set/formatter/base.rb', line 172 def initialize(out = nil, err = nil) @out_to = out || ::Command::raw_stdout @err_to = err || ::Command::raw_stderr super() end |
Class Method Details
.inherited(sub) ⇒ Object
180 181 182 183 184 185 |
# File 'lib/command-set/formatter/base.rb', line 180 def self.inherited(sub) sub.extend Forwardable sub.class_eval do def_delegators :@out_to, :p, :puts, :print, :printf, :putc, :write, :write_nonblock, :flush end end |
Instance Method Details
#closed_item(value) ⇒ Object
187 188 189 |
# File 'lib/command-set/formatter/base.rb', line 187 def closed_item(value) puts value end |