Class: SRSGame::Settings

Inherits:
Object show all
Defined in:
lib/srs_game.rb,
lib/srs_game.rb

Overview

:doc:

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.envObject (readonly)

Returns the value of attribute env



272
273
274
# File 'lib/srs_game.rb', line 272

def env
  @env
end

Class Method Details

.[](key) ⇒ Object

S is the same as S.env



282
283
284
# File 'lib/srs_game.rb', line 282

def [](key)
  @env[key.to_s.upcase]
end

.apply!Object

Apply settings. TODO: make these things configurable.



288
289
290
291
292
293
294
295
# File 'lib/srs_game.rb', line 288

def self.apply!
  Readline.completion_append_character = " "
  puts "Howdy, partner!" if S[:says_howdy_partner].to_s.to_bool
  if S[:matches_short_methods].to_bool
    completion_proc = proc { |s| command.matching_methods(s).map(&:command_pp) }
    Readline.completion_proc = completion_proc
  end # if
end

.default_settingsObject

SRS GAME's default settings



298
299
300
301
302
303
304
# File 'lib/srs_game.rb', line 298

def self.default_settings
  {
    "GREETING_SPEED" => 20,
    "SAYS_HOWDY_PARTNER" => false,
    "MATCHES_SHORT_METHODS" => true
  }
end

.seed(seed) ⇒ Object

Add what we are seeding to @env



275
276
277
278
279
# File 'lib/srs_game.rb', line 275

def seed(seed)
  @env ||= default_settings
  @env << seed
  self
end