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.



163
164
165
166
# File 'lib/bgem.rb', line 163

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

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



168
169
170
# File 'lib/bgem.rb', line 168

def file
  @file
end

Instance Method Details

#[](string) ⇒ Object



170
171
172
173
174
175
176
177
178
179
180
# File 'lib/bgem.rb', line 170

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