Class: Xsdvi::Utils::Writer
- Inherits:
-
Object
- Object
- Xsdvi::Utils::Writer
- Defined in:
- lib/xsdvi/utils/writer.rb
Overview
Helper class for writing output files
Constant Summary collapse
- DEFAULT_CHARSET =
"UTF-8"
Instance Attribute Summary collapse
-
#writer ⇒ Object
readonly
Returns the value of attribute writer.
Instance Method Summary collapse
- #append(content) ⇒ Object
- #close ⇒ Object
-
#initialize(uri = nil, charset_name = DEFAULT_CHARSET) ⇒ Writer
constructor
A new instance of Writer.
- #new_writer(uri, charset_name = DEFAULT_CHARSET) ⇒ Object
Constructor Details
#initialize(uri = nil, charset_name = DEFAULT_CHARSET) ⇒ Writer
Returns a new instance of Writer.
11 12 13 |
# File 'lib/xsdvi/utils/writer.rb', line 11 def initialize(uri = nil, charset_name = DEFAULT_CHARSET) new_writer(uri, charset_name) if uri end |
Instance Attribute Details
#writer ⇒ Object (readonly)
Returns the value of attribute writer.
9 10 11 |
# File 'lib/xsdvi/utils/writer.rb', line 9 def writer @writer end |
Instance Method Details
#append(content) ⇒ Object
19 20 21 22 |
# File 'lib/xsdvi/utils/writer.rb', line 19 def append(content) writer&.write(content) writer end |
#close ⇒ Object
15 16 17 |
# File 'lib/xsdvi/utils/writer.rb', line 15 def close writer&.close end |
#new_writer(uri, charset_name = DEFAULT_CHARSET) ⇒ Object
24 25 26 |
# File 'lib/xsdvi/utils/writer.rb', line 24 def new_writer(uri, charset_name = DEFAULT_CHARSET) @writer = File.open(uri, "w:#{charset_name}") end |