Class: Abstracta::Occupant
- Inherits:
-
Object
- Object
- Abstracta::Occupant
- Extended by:
- Forwardable
- Defined in:
- lib/abstracta/occupant.rb
Instance Attribute Summary collapse
-
#age ⇒ Object
readonly
Returns the value of attribute age.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
Instance Method Summary collapse
-
#initialize(location = [0,0]) ⇒ Occupant
constructor
A new instance of Occupant.
- #position ⇒ Object
- #step ⇒ Object
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
#age ⇒ Object (readonly)
Returns the value of attribute age.
4 5 6 |
# File 'lib/abstracta/occupant.rb', line 4 def age @age end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
5 6 7 |
# File 'lib/abstracta/occupant.rb', line 5 def location @location end |
Instance Method Details
#position ⇒ Object
14 |
# File 'lib/abstracta/occupant.rb', line 14 def position; [@x,@y] end |
#step ⇒ Object
16 17 18 |
# File 'lib/abstracta/occupant.rb', line 16 def step @age = @age + 1 end |