Class: CC2HTML::HtmlBuilder

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

Constant Summary collapse

TEMPLATE_DIR =
'../templates/html/'

Instance Method Summary collapse

Constructor Details

#initialize(manifest, dest_dir, zip_file) ⇒ HtmlBuilder

Returns a new instance of HtmlBuilder.



4
5
6
7
8
# File 'lib/cc2html/html_builder.rb', line 4

def initialize(manifest, dest_dir, zip_file)
  @manifest = manifest
  @dest_name = dest_dir
  @root_items = manifest.organizations.organization.item.items
end

Instance Method Details

#generateObject



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/cc2html/html_builder.rb', line 10

def generate
  FileUtils.mkdir_p(@dest_name)
  template = File.expand_path(TEMPLATE_DIR + 'index.html.erb', __FILE__)
  path = File.join(@dest_name, 'index.html')

  #FileUtils.mkdir_p(File.dirname(path))
  File.open(path, 'w') do |file|
    erb = ERB.new(File.read(template))
    file.write(erb.result(binding))
  end
end