Class: Smagacor::Configuration
Instance Attribute Summary collapse
-
#games ⇒ Object
readonly
Returns the value of attribute games.
-
#gamespath ⇒ Object
readonly
Returns the value of attribute gamespath.
-
#homepath ⇒ Object
readonly
Returns the value of attribute homepath.
Instance Method Summary collapse
- #get_file(file) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #load_games ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/smagacor/util.rb', line 190 def initialize @gamespath = [ File.join( ::Config::CONFIG["datadir"], "smagacor" ), 'data/smagacor' ] if defined?( Gem::Cache ) gem = Gem::Cache.from_installed_gems.search( "smagacor", "=#{::Smagacor::VERSION.join('.')}" ).last @gamespath << File.join( gem.full_gem_path, "data", "smagacor" ) if gem end begin homepath = File.( '~' ) rescue homepath = ENV['USERPROFILE'] || ENV['HOMEDRIVE']+ENV['HOMEPATH'] end @homepath = File.join( homepath, '.smagacor' ) @gamespath.unshift( @homepath ) @games = [] end |
Instance Attribute Details
#games ⇒ Object (readonly)
Returns the value of attribute games.
187 188 189 |
# File 'lib/smagacor/util.rb', line 187 def games @games end |
#gamespath ⇒ Object (readonly)
Returns the value of attribute gamespath.
186 187 188 |
# File 'lib/smagacor/util.rb', line 186 def gamespath @gamespath end |
#homepath ⇒ Object (readonly)
Returns the value of attribute homepath.
188 189 190 |
# File 'lib/smagacor/util.rb', line 188 def homepath @homepath end |
Instance Method Details
#get_file(file) ⇒ Object
206 207 208 209 210 211 |
# File 'lib/smagacor/util.rb', line 206 def get_file( file ) @gamespath.each do |path| name = File.join( path, file ) return name if File.exists?( name ) end end |
#load_games ⇒ Object
213 214 215 216 217 218 219 220 221 222 |
# File 'lib/smagacor/util.rb', line 213 def load_games @games = [] @gamespath.each do |path| Dir[path + '/*/game.info'].each do |file| gi = YAML::load( File.open( file ) ) gi.directory = File.dirname( file ) @games.push( gi ) end end end |