Class: Bgem::TargetFile

Inherits:
Object
  • Object
show all
Defined in:
lib/bgem.rb

Instance Method Summary collapse

Constructor Details

#initialize(path = 'output.rb', scope) ⇒ TargetFile

Returns a new instance of TargetFile.



108
109
110
111
# File 'lib/bgem.rb', line 108

def initialize path = 'output.rb', scope
  @path = Pathname path
  @scope = scope
end

Instance Method Details

#fileObject



125
126
127
# File 'lib/bgem.rb', line 125

def file
  @path
end

#write(string) ⇒ Object



113
114
115
116
117
118
119
120
121
122
123
# File 'lib/bgem.rb', line 113

def write string
  @path.dirname.mkpath

  if @scope
    @scope.each do |header|
      string = "#{header}\n#{string.indent INDENT}\nend"
    end
  end

  @path.write "#{string}\n"
end