Class: RubyBindgen::Outputter
- Inherits:
-
Object
- Object
- RubyBindgen::Outputter
- Defined in:
- lib/ruby-bindgen/outputter.rb
Instance Attribute Summary collapse
-
#base_path ⇒ Object
readonly
Returns the value of attribute base_path.
-
#output_paths ⇒ Object
readonly
Returns the value of attribute output_paths.
Instance Method Summary collapse
-
#initialize(base_path) ⇒ Outputter
constructor
A new instance of Outputter.
- #output_path(relative_path) ⇒ Object
- #write(relative_path, content) ⇒ Object
Constructor Details
#initialize(base_path) ⇒ Outputter
Returns a new instance of Outputter.
10 11 12 13 |
# File 'lib/ruby-bindgen/outputter.rb', line 10 def initialize(base_path) @base_path = base_path @output_paths = {} end |
Instance Attribute Details
#base_path ⇒ Object (readonly)
Returns the value of attribute base_path.
8 9 10 |
# File 'lib/ruby-bindgen/outputter.rb', line 8 def base_path @base_path end |
#output_paths ⇒ Object (readonly)
Returns the value of attribute output_paths.
8 9 10 |
# File 'lib/ruby-bindgen/outputter.rb', line 8 def output_paths @output_paths end |
Instance Method Details
#output_path(relative_path) ⇒ Object
15 16 17 |
# File 'lib/ruby-bindgen/outputter.rb', line 15 def output_path(relative_path) File.(File.join(self.base_path, relative_path)) end |
#write(relative_path, content) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/ruby-bindgen/outputter.rb', line 19 def write(relative_path, content) path = self.output_path(relative_path) cleaned = cleanup_whitespace(content) FileUtils.mkdir_p(File.dirname(path)) File.open(path, "wb") do |file| file << cleaned end @output_paths[path] = cleaned end |