Class: Entityjs::Config

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



49
50
51
# File 'lib/entityjs/config.rb', line 49

def initialize
  self.reload
end

Class Method Details

.assets_folderObject



11
12
13
# File 'lib/entityjs/config.rb', line 11

def self.assets_folder
  return 'assets'
end

.builds_folderObject



23
24
25
# File 'lib/entityjs/config.rb', line 23

def self.builds_folder
  return 'builds'
end

.file_nameObject



7
8
9
# File 'lib/entityjs/config.rb', line 7

def self.file_name
  'config.yml'
end

.images_folderObject



31
32
33
# File 'lib/entityjs/config.rb', line 31

def self.images_folder
  self.assets_folder+'/images'
end

.instanceObject



35
36
37
38
39
40
41
# File 'lib/entityjs/config.rb', line 35

def self.instance
  if @instance.nil?
    @instance = Config.new
  end
  
  return @instance
end

.scripts_folderObject



19
20
21
# File 'lib/entityjs/config.rb', line 19

def self.scripts_folder
  return 'scripts'
end

.sounds_folderObject



27
28
29
# File 'lib/entityjs/config.rb', line 27

def self.sounds_folder
  self.assets_folder+'/sounds'
end

.tests_folderObject



15
16
17
# File 'lib/entityjs/config.rb', line 15

def self.tests_folder
  'tests'
end

Instance Method Details

#canvas_borderObject



60
61
62
63
64
65
66
# File 'lib/entityjs/config.rb', line 60

def canvas_border
  if @yml.nil?
    return true
  end
  
  return @yml['canvas-border'] || true
end

#canvas_idObject



119
120
121
122
123
124
125
# File 'lib/entityjs/config.rb', line 119

def canvas_id
  if @yml.nil?
    return 'game-canvas'
  end
  
  @yml['canvas-id'] || 'game-canvas'
end

#entity_ignoreObject



108
109
110
111
112
113
114
115
116
117
# File 'lib/entityjs/config.rb', line 108

def entity_ignore
  if @yml.nil?
    return []
  end
  
  y = @yml['entity-ignore']
  if !y.nil?
    y.split(" ")
  end
end

#heightObject



68
69
70
71
72
73
# File 'lib/entityjs/config.rb', line 68

def height
  if @yml.nil?
    return 400
  end
  @yml['height'] || 400
end

#licenseObject



127
128
129
130
131
132
133
# File 'lib/entityjs/config.rb', line 127

def license
  contents = IO.read(Entityjs::root+'/license.txt')
  
  contents = contents.sub(/\$VERSION/, Entityjs::VERSION)
  
  return contents+"\n"
end

#reloadObject



43
44
45
46
47
# File 'lib/entityjs/config.rb', line 43

def reload
  if File.exists?(Config.file_name)
    @yml = YAML::load(File.open(Config.file_name))
  end
end

#scripts_ignoreObject



75
76
77
78
79
80
81
82
83
84
# File 'lib/entityjs/config.rb', line 75

def scripts_ignore
  if @yml.nil?
    return []
  end
  
  y = @yml['scripts-ignore']
  if !y.nil?
    y.split(" ")
  end
end

#scripts_orderObject



86
87
88
89
90
91
92
93
94
95
# File 'lib/entityjs/config.rb', line 86

def scripts_order
  if @yml.nil?
    return []
  end
  
  y = @yml['order']
  if !y.nil?
    y.split(" ")
  end
end

#tests_ignoreObject



97
98
99
100
101
102
103
104
105
106
# File 'lib/entityjs/config.rb', line 97

def tests_ignore
  if @yml.nil?
    return []
  end
  
  y = @yml['tests-ignore']
  if !y.nil?
    y.split(" ")
  end
end

#widthObject



53
54
55
56
57
58
# File 'lib/entityjs/config.rb', line 53

def width
  if @yml.nil?
    return 500
  end
  @yml['width'] || 500
end