#!/usr/bin/ruby require 'erb' pngs = Dir['resources/*.png'].map { |path| File.basename(path, '.png') } template = ERB.new <<-EOF package { public class TileModel extends GameObjectModel { <% pngs.each_with_index do |png, i| %> public static const TILE_<%= png %>:int = <%= i %>;<% end %> public var tileType:int; public function TileModel(tileType:int, positionX:int = 0, positionZ:int = 0) { super(); this.tileType = tileType; position.x = positionX; position.z = positionZ; } public function get isFloor():Boolean { return false<% pngs.each do |png| %><% if png =~ /Floor/ then %> || tileType == TILE_<%= png %><% end %><% end %>; } public static function isSolidTileType(tileType:int):Boolean { return !(tileType == -1<% pngs.each do |png| %><% if png =~ /DoorFrame/ || png =~ /Edge/ then %> || tileType == TILE_<%= png %><% end %><% end %>); } } } EOF puts template.result(binding)