Class: Fudge::Formatters::Simple::Writer
- Inherits:
-
Object
- Object
- Fudge::Formatters::Simple::Writer
- Defined in:
- lib/fudge/formatters/simple.rb
Overview
Internal wrapper for output
Class Method Summary collapse
-
.wrap(*methods) ⇒ Object
Determines which formatter methods to make available.
Instance Method Summary collapse
-
#initialize(formatter) ⇒ Writer
constructor
A new instance of Writer.
-
#write(out) ⇒ Object
Writes the final message.
Constructor Details
#initialize(formatter) ⇒ Writer
Returns a new instance of Writer.
18 19 20 21 |
# File 'lib/fudge/formatters/simple.rb', line 18 def initialize(formatter) @parts = [] @formatter = formatter end |
Class Method Details
.wrap(*methods) ⇒ Object
Determines which formatter methods to make available
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fudge/formatters/simple.rb', line 29 def self.wrap(*methods) methods.each do |m| class_eval <<-RUBY def #{m}(message) @parts << @formatter.#{m}(message) self end RUBY end end |
Instance Method Details
#write(out) ⇒ Object
Writes the final message
24 25 26 |
# File 'lib/fudge/formatters/simple.rb', line 24 def write(out) out.puts @parts.join(' ') end |