Module: Lucid::WindowsOutput

Extended by:
WindowsOutput
Included in:
WindowsOutput
Defined in:
lib/lucid/formatter/unicode.rb

Class Method Summary collapse

Class Method Details

.extended(o) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/lucid/formatter/unicode.rb', line 24

def self.extended(o)
  o.instance_eval do

    def lucid_preprocess_output(*a)
      begin
        a.map{|arg| arg.to_s.encode(Encoding.default_external)}
      rescue Encoding::UndefinedConversionError => e
        STDERR.lucid_puts("WARNING: #{e.message}")
        a
      end
    end

    alias lucid_print print
    def print(*a)
      lucid_print(*lucid_preprocess_output(*a))
    end

    alias lucid_puts puts
    def puts(*a)
      lucid_puts(*lucid_preprocess_output(*a))
    end
  end
end