Class: Tidy::Axml
- Inherits:
-
Object
- Object
- Tidy::Axml
- Defined in:
- lib/tidy/axml.rb
Instance Method Summary collapse
- #getFirstExistingFileFromArray(files) ⇒ Object
-
#initialize(args) ⇒ Axml
constructor
A new instance of Axml.
Constructor Details
#initialize(args) ⇒ Axml
Returns a new instance of Axml.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/tidy/axml.rb', line 4 def initialize(args) @main = args[:main] @output = args[:output] @id = args[:id] || @output @version = (args[:version] || "1").to_s.strip @app_name = args[:app_name] || @output.to_s.gsub("_","") @filename = @output @content = "#{@output}.swf" @width = args[:width] || 1200 @height = args[:height] || 900 # check which if application template is available use array locations = [ "config/templates/#{@output}.axml.erb", "config/templates/air.axml.erb" ] source = File.read(getFirstExistingFileFromArray(locations)) axml_file = "bin/#{@output}.axml" puts "Air template with main:#{@main}, @output:#{@output}, id:#{@id}, @version:#{@version}, @app_name:#{@app_name}, filename:#{@filename}" template = ERB.new(source) File.open(axml_file,'w') do |f| f << template.result(binding) end end |
Instance Method Details
#getFirstExistingFileFromArray(files) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/tidy/axml.rb', line 34 def getFirstExistingFileFromArray(files) files.each do |file| if File.exists?(file) return file end end raise "CAN'T find existing file in #{files.inspect} running in #{File.expand_path('.')}" # throw error end |