Class: REXML::Output

Inherits:
Object show all
Includes:
Encoding
Defined in:
lib/extensions/rexml/rexml/output.rb

Constant Summary

Constants included from Encoding

Encoding::UNILE, Encoding::UTF_16, Encoding::UTF_8

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Encoding

apply, #check_encoding, #decode_ascii, #decode_cp1252, #decode_iconv, #decode_unile, #decode_utf16, #decode_utf8, #encode_ascii, #encode_cp1252, #encode_iconv, #encode_unile, #encode_utf16, #encode_utf8, encoding_method, #from_iso_8859_15, register, #to_iso_8859_15

Constructor Details

#initialize(real_IO, encd = "iso-8859-1") ⇒ Output

Returns a new instance of Output.



9
10
11
12
13
14
# File 'lib/extensions/rexml/rexml/output.rb', line 9

def initialize real_IO, encd="iso-8859-1"
  @output = real_IO
  self.encoding = encd

  @to_utf = encd == UTF_8 ? false : true
end

Instance Attribute Details

#encodingObject (readonly)

Returns the value of attribute encoding.



7
8
9
# File 'lib/extensions/rexml/rexml/output.rb', line 7

def encoding
  @encoding
end

Instance Method Details

#<<(content) ⇒ Object



16
17
18
# File 'lib/extensions/rexml/rexml/output.rb', line 16

def <<( content )
  @output << (@to_utf ? self.encode(content) : content)
end

#to_sObject



20
21
22
# File 'lib/extensions/rexml/rexml/output.rb', line 20

def to_s
  "Output[#{encoding}]"
end