Class: Entityjs::Assets
- Inherits:
-
Object
- Object
- Entityjs::Assets
- Defined in:
- lib/entityjs/assets.rb
Class Method Summary collapse
- .find_files(search) ⇒ Object
- .search(type = nil) ⇒ Object
- .search_datas ⇒ Object
- .valid_images ⇒ Object
- .valid_sounds ⇒ Object
Class Method Details
.find_files(search) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# 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) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# 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 ⇒ Object
34 35 36 37 38 |
# 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 ⇒ Object
6 7 8 |
# File 'lib/entityjs/assets.rb', line 6 def self.valid_images ['gif', 'png', 'jpg', 'jpeg'] end |
.valid_sounds ⇒ Object
10 11 12 |
# File 'lib/entityjs/assets.rb', line 10 def self.valid_sounds ['mp3', 'ogg', 'aac', 'wav'] end |