Class: Rubinstein::World

Inherits:
Object
  • Object
show all
Defined in:
lib/rubinstein/world.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, &block) ⇒ World

Returns a new instance of World.



6
7
8
9
10
11
12
# File 'lib/rubinstein/world.rb', line 6

def initialize(name,&block)
  @name       = name
  @locations  = {}
  @player     = Player.new

  instance_eval &block
end

Instance Attribute Details

#locationsObject

Returns the value of attribute locations.



4
5
6
# File 'lib/rubinstein/world.rb', line 4

def locations
  @locations
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/rubinstein/world.rb', line 4

def name
  @name
end

#playerObject

Returns the value of attribute player.



4
5
6
# File 'lib/rubinstein/world.rb', line 4

def player
  @player
end

Instance Method Details

#location(name, &block) ⇒ Object



14
15
16
# File 'lib/rubinstein/world.rb', line 14

def location(name,&block)
  @locations[name] = Location.new(name,&block)
end

#start(location) ⇒ Object



18
19
20
# File 'lib/rubinstein/world.rb', line 18

def start(location)
  @player.location = @locations[location]
end