Class: Xdrgen::Output
- Inherits:
-
Object
- Object
- Xdrgen::Output
- Defined in:
- lib/xdrgen/output.rb
Instance Attribute Summary collapse
-
#output_dir ⇒ Object
readonly
Returns the value of attribute output_dir.
-
#source_paths ⇒ Object
readonly
Returns the value of attribute source_paths.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(source_paths, output_dir) ⇒ Output
constructor
A new instance of Output.
- #open(child_path) {|result| ... } ⇒ Object
- #write(child_path, content) ⇒ Object
Constructor Details
#initialize(source_paths, output_dir) ⇒ Output
Returns a new instance of Output.
9 10 11 12 13 |
# File 'lib/xdrgen/output.rb', line 9 def initialize(source_paths, output_dir) @source_paths = source_paths @output_dir = output_dir @files = {} end |
Instance Attribute Details
#output_dir ⇒ Object (readonly)
Returns the value of attribute output_dir.
7 8 9 |
# File 'lib/xdrgen/output.rb', line 7 def output_dir @output_dir end |
#source_paths ⇒ Object (readonly)
Returns the value of attribute source_paths.
6 7 8 |
# File 'lib/xdrgen/output.rb', line 6 def source_paths @source_paths end |
Instance Method Details
#close ⇒ Object
32 33 34 |
# File 'lib/xdrgen/output.rb', line 32 def close @files.values.each(&:close) end |
#open(child_path) {|result| ... } ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/xdrgen/output.rb', line 15 def open(child_path) if @files.has_key?(child_path) raise Xdrgen::DuplicateFileError, "Cannot open #{child_path} twice" end path = File.join @output_dir, child_path result = @files[child_path] = OutputFile.new(path) yield result if block_given? result end |
#write(child_path, content) ⇒ Object
28 29 30 |
# File 'lib/xdrgen/output.rb', line 28 def write(child_path, content) open(child_path){|c| c.puts content} end |