Class: ControllerWriter

Inherits:
Object
  • Object
show all
Defined in:
app/writers/controller_writer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data_table) ⇒ ControllerWriter

Returns a new instance of ControllerWriter.



3
4
5
# File 'app/writers/controller_writer.rb', line 3

def initialize(data_table)
  @data_table = data_table
end

Instance Attribute Details

#data_tableObject (readonly)

Returns the value of attribute data_table.



2
3
4
# File 'app/writers/controller_writer.rb', line 2

def data_table
  @data_table
end

Instance Method Details

#writeObject



7
8
9
10
11
12
13
14
15
16
17
# File 'app/writers/controller_writer.rb', line 7

def write
  if File.exists?(filename)
    puts "Controller already defined for #{data_table.name}. Skipping"
    return
  end
  FileUtils.mkdir_p('app/controllers/gatherable')
  File.open(filename, 'w') do |f|
    f.puts controller_contents
  end
  puts "created #{filename}" if File.exists?(filename)
end