class Entityjs::Assets
Public Class Methods
find_files(search)
click to toggle source
# File lib/entityjs/assets.rb, line 40 def self.find_files(search) Dir.glob(Dirc.game_root+'/'+search).collect do |i| if File.file?(i) #remove long string i = i.split(Config.assets_folder+"/").pop end end.compact #remove nils from array too end
search(type=nil)
click to toggle source
# File lib/entityjs/assets.rb, line 14 def self.search(type=nil) case type when 'images' images_folder = Config.images_folder valid_images = self.valid_images.join(',') return self.find_files(images_folder+"/**/*.{#{valid_images}}") when 'sounds' sounds_folder = Config.sounds_folder valid_sounds = self.valid_sounds.join(',') return self.find_files(sounds_folder+"/**/*.{#{valid_sounds}}") else return self.find_files(Config.assets_folder+'/**/*') end end
search_datas()
click to toggle source
# File lib/entityjs/assets.rb, line 34 def self.search_datas #TODO: find all other folders and generate a key in re.assets #DEPRECATED return self.find_files("#{Config.assets_folder}/*/*").select{|i| i.match(/(images|sounds)\//i) == nil } end
valid_images()
click to toggle source
# File lib/entityjs/assets.rb, line 6 def self.valid_images ['gif', 'png', 'jpg', 'jpeg'] end
valid_sounds()
click to toggle source
# File lib/entityjs/assets.rb, line 10 def self.valid_sounds ['mp3', 'ogg', 'aac', 'wav'] end