Class: Abstracta::Occupant

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/abstracta/occupant.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(location = [0,0]) ⇒ Occupant

Returns a new instance of Occupant.



8
9
10
11
12
# File 'lib/abstracta/occupant.rb', line 8

def initialize(location=[0,0])
  @location = location
  @age      = 0
  @size     = 1
end

Instance Attribute Details

#ageObject (readonly)

Returns the value of attribute age.



4
5
6
# File 'lib/abstracta/occupant.rb', line 4

def age
  @age
end

#locationObject (readonly)

Returns the value of attribute location.



5
6
7
# File 'lib/abstracta/occupant.rb', line 5

def location
  @location
end

Instance Method Details

#positionObject



14
# File 'lib/abstracta/occupant.rb', line 14

def position; [@x,@y] end

#stepObject



16
17
18
# File 'lib/abstracta/occupant.rb', line 16

def step
  @age = @age + 1
end