Class: Entityjs::Assets

Inherits:
Object
  • Object
show all
Defined in:
lib/entityjs/assets.rb

Class Method Summary collapse

Class Method Details

.find_files(search) ⇒ Object



40
41
42
43
44
45
# File 'lib/entityjs/assets.rb', line 40

def self.find_files(search)
  Dir[Dirc.game_root+'/'+search].collect do |i|
    #remove long string
    i = i.split("assets/").pop
  end
end

.search(type = '*') ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/entityjs/assets.rb', line 14

def self.search(type='*')
  
  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
      #TODO: fix up
      return self.search_datas
      
  end
  
end

.search_datasObject



35
36
37
38
# File 'lib/entityjs/assets.rb', line 35

def self.search_datas
  #TODO: find all other folders and generate a key in re.assets
  return self.find_files("#{Config.assets_folder}/*/*").select{|i| i.match(/(images|sounds)\//i) == nil }
end

.valid_imagesObject



6
7
8
# File 'lib/entityjs/assets.rb', line 6

def self.valid_images
  ['gif', 'png', 'jpg', 'jpeg']
end

.valid_soundsObject



10
11
12
# File 'lib/entityjs/assets.rb', line 10

def self.valid_sounds
  ['mp3', 'ogg', 'aac', 'wav']
end