Class: Bgem::Write

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Write

Returns a new instance of Write.



315
316
317
318
# File 'lib/bgem.rb', line 315

def initialize config
  @file = Pathname config.output
  @scope = config.scope
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



320
321
322
# File 'lib/bgem.rb', line 320

def file
  @file
end

Instance Method Details

#[](string) ⇒ Object



322
323
324
325
326
327
328
329
330
331
332
# File 'lib/bgem.rb', line 322

def [] string
  file.dirname.mkpath

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

  file.write "#{string}\n"
end