Module: AssLauncher::Support::V8iFile
- Defined in:
- lib/ass_launcher/support/v8i_file.rb
Overview
v8i file reader-writer
Defined Under Namespace
Classes: ReadError
Class Method Summary collapse
-
.load(filename) ⇒ Array<V8iSection>
Read v8i file.
-
.read(io) ⇒ Array<V8iSection>
Read v8i content and return array of v8i sections.
-
.save(filename, sections) ⇒ Object
Save sections in to v8i file.
-
.write(io, sections) ⇒ Object
Write sections in to output stream.
Class Method Details
.load(filename) ⇒ Array<V8iSection>
Read v8i file
28 29 30 31 32 |
# File 'lib/ass_launcher/support/v8i_file.rb', line 28 def self.load(filename) fail ReadError, "File #{filename} not exist or not a file"\ unless File.file? filename read File.new(filename, 'r:bom|utf-8') end |
.read(io) ⇒ Array<V8iSection>
Read v8i content and return array of v8i sections
15 16 17 18 19 20 21 22 |
# File 'lib/ass_launcher/support/v8i_file.rb', line 15 def self.read(io) res = [] inifile = to_inifile(io.read) inifile.each_section do || res << V8iSection.new(, inifile[]) end res end |
.save(filename, sections) ⇒ Object
Save sections in to v8i file
46 47 48 49 50 |
# File 'lib/ass_launcher/support/v8i_file.rb', line 46 def self.save(filename, sections) f = File.new(filename, 'w') write f, sections f.close end |
.write(io, sections) ⇒ Object
Write sections in to output stream
37 38 39 40 41 |
# File 'lib/ass_launcher/support/v8i_file.rb', line 37 def self.write(io, sections) sections.each do |s| io.write(s.to_s + "\r\n") end end |