Class: Xsdvi::Utils::Writer

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#writerObject (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

#closeObject



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