Class: Dictionary
- Inherits:
-
Object
- Object
- Dictionary
- Defined in:
- lib/ruby-doom.rb
Class Method Summary collapse
Instance Method Summary collapse
- #direction_for_angle(angle) ⇒ Object
-
#initialize ⇒ Dictionary
constructor
A new instance of Dictionary.
- #thing_for_name(name) ⇒ Object
- #thing_for_type_id(id) ⇒ Object
Constructor Details
#initialize ⇒ Dictionary
Returns a new instance of Dictionary.
271 272 273 274 275 276 277 278 279 |
# File 'lib/ruby-doom.rb', line 271 def initialize @things = [] @things << ThingInfo.new(1, "Player 1", "@") @things << ThingInfo.new(9, "Sergeant", "s") @things << ThingInfo.new(65, "Commando", "c") @things << ThingInfo.new(2001, "Shotgun", "g") @things << ThingInfo.new(3001, "Imp", "i") @things << ThingInfo.new(2035, "Barrel", "b") end |
Class Method Details
.get ⇒ Object
265 266 267 268 269 270 |
# File 'lib/ruby-doom.rb', line 265 def Dictionary.get if @self.nil? @self = Dictionary.new end return @self end |
Instance Method Details
#direction_for_angle(angle) ⇒ Object
288 289 290 291 292 293 294 295 296 |
# File 'lib/ruby-doom.rb', line 288 def direction_for_angle(angle) case angle when (0..45 or 316..360) then return "east" when 46..135 then return "north" when 136..225 then return "west" when 225..315 then return "south" end raise "Angle must be between 0 and 360" end |
#thing_for_name(name) ⇒ Object
285 286 287 |
# File 'lib/ruby-doom.rb', line 285 def thing_for_name(name) @things.find {|x| x.name == name} end |