Class: RubyBindgen::Outputter

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-bindgen/outputter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_pathObject (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_pathsObject (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.expand_path(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